xrpld
Loading...
Searching...
No Matches
xrpl::peer_finder::Counts Class Reference

Manages the count of available connections for the various slots. More...

#include <Counts.h>

Collaboration diagram for xrpl::peer_finder::Counts:

Public Member Functions

void add (Slot const &s)
 Adds the slot state and properties to the slot counts.
void remove (Slot const &s)
 Removes the slot state and properties from the slot counts.
bool canActivate (Slot const &s) const
 Returns true if the slot can become active.
std::size_t attemptsNeeded () const
 Returns the number of attempts needed to bring us to the max.
std::size_t attempts () const
 Returns the number of outbound connection attempts.
int outMax () const
 Returns the total number of outbound slots.
int outActive () const
 Returns the number of outbound peers assigned an open slot.
std::size_t fixed () const
 Returns the number of fixed connections.
std::size_t fixedActive () const
 Returns the number of active fixed connections.
void onConfig (Config const &config)
 Called when the config is set or changed.
int acceptCount () const
 Returns the number of accepted connections that haven't handshaked.
int connectCount () const
 Returns the number of connection attempts currently active.
int closingCount () const
 Returns the number of connections that are gracefully closing.
int inMax () const
 Returns the total number of inbound slots.
int inboundActive () const
 Returns the number of inbound peers assigned an open slot.
int totalActive () const
 Returns the total number of active peers excluding fixed peers.
int inboundSlotsFree () const
 Returns the number of unused inbound slots.
int outboundSlotsFree () const
 Returns the number of unused outbound slots.
bool isConnectedToNetwork () const
 Returns true if the slot logic considers us "connected" to the network.
void onWrite (beast::PropertyStream::Map &map) const
 Output statistics.
std::string stateString () const
 Records the state for diagnostics.

Private Member Functions

void adjust (Slot const &s, CountAdjustment const dir)

Static Private Member Functions

template<typename T>
static void adjustCounter (T &counter, CountAdjustment dir)
 Increments or decrements a counter based on the adjustment direction.

Private Attributes

int attempts_ {0}
 Outbound connection attempts.
std::size_t active_ {0}
 Active connections, including fixed and reserved.
std::size_t inMax_ {0}
 Total number of inbound slots.
std::size_t inActive_ {0}
 Number of inbound slots assigned to active peers.
std::size_t outMax_ {0}
 Maximum desired outbound slots.
std::size_t outActive_ {0}
 Active outbound slots.
std::size_t fixed_ {0}
 Fixed connections.
std::size_t fixedActive_ {0}
 Active fixed connections.
std::size_t reserved_ {0}
 Reserved connections.
int acceptCount_ {0}
int closingCount_ {0}

Detailed Description

Manages the count of available connections for the various slots.

Definition at line 23 of file Counts.h.

Member Function Documentation

◆ add()

void xrpl::peer_finder::Counts::add ( Slot const & s)

Adds the slot state and properties to the slot counts.

Definition at line 30 of file Counts.h.

◆ remove()

void xrpl::peer_finder::Counts::remove ( Slot const & s)

Removes the slot state and properties from the slot counts.

Definition at line 39 of file Counts.h.

◆ canActivate()

bool xrpl::peer_finder::Counts::canActivate ( Slot const & s) const
nodiscard

Returns true if the slot can become active.

Definition at line 48 of file Counts.h.

◆ attemptsNeeded()

std::size_t xrpl::peer_finder::Counts::attemptsNeeded ( ) const
nodiscard

Returns the number of attempts needed to bring us to the max.

Definition at line 68 of file Counts.h.

◆ attempts()

std::size_t xrpl::peer_finder::Counts::attempts ( ) const
nodiscard

Returns the number of outbound connection attempts.

Definition at line 79 of file Counts.h.

◆ outMax()

int xrpl::peer_finder::Counts::outMax ( ) const
nodiscard

Returns the total number of outbound slots.

Definition at line 88 of file Counts.h.

◆ outActive()

int xrpl::peer_finder::Counts::outActive ( ) const
nodiscard

Returns the number of outbound peers assigned an open slot.

Fixed peers do not count towards outbound slots used.

Definition at line 98 of file Counts.h.

◆ fixed()

std::size_t xrpl::peer_finder::Counts::fixed ( ) const
nodiscard

Returns the number of fixed connections.

Definition at line 107 of file Counts.h.

◆ fixedActive()

std::size_t xrpl::peer_finder::Counts::fixedActive ( ) const
nodiscard

Returns the number of active fixed connections.

Definition at line 116 of file Counts.h.

◆ onConfig()

void xrpl::peer_finder::Counts::onConfig ( Config const & config)

Called when the config is set or changed.

Definition at line 127 of file Counts.h.

◆ acceptCount()

int xrpl::peer_finder::Counts::acceptCount ( ) const
nodiscard

Returns the number of accepted connections that haven't handshaked.

Definition at line 138 of file Counts.h.

◆ connectCount()

int xrpl::peer_finder::Counts::connectCount ( ) const
nodiscard

Returns the number of connection attempts currently active.

Definition at line 147 of file Counts.h.

◆ closingCount()

int xrpl::peer_finder::Counts::closingCount ( ) const
nodiscard

Returns the number of connections that are gracefully closing.

Definition at line 156 of file Counts.h.

◆ inMax()

int xrpl::peer_finder::Counts::inMax ( ) const
nodiscard

Returns the total number of inbound slots.

Definition at line 165 of file Counts.h.

◆ inboundActive()

int xrpl::peer_finder::Counts::inboundActive ( ) const
nodiscard

Returns the number of inbound peers assigned an open slot.

Definition at line 174 of file Counts.h.

◆ totalActive()

int xrpl::peer_finder::Counts::totalActive ( ) const
nodiscard

Returns the total number of active peers excluding fixed peers.

Definition at line 183 of file Counts.h.

◆ inboundSlotsFree()

int xrpl::peer_finder::Counts::inboundSlotsFree ( ) const
nodiscard

Returns the number of unused inbound slots.

Fixed peers do not deduct from inbound slots or count towards totals.

Definition at line 193 of file Counts.h.

◆ outboundSlotsFree()

int xrpl::peer_finder::Counts::outboundSlotsFree ( ) const
nodiscard

Returns the number of unused outbound slots.

Fixed peers do not deduct from outbound slots or count towards totals.

Definition at line 205 of file Counts.h.

◆ isConnectedToNetwork()

bool xrpl::peer_finder::Counts::isConnectedToNetwork ( ) const
nodiscard

Returns true if the slot logic considers us "connected" to the network.

Definition at line 218 of file Counts.h.

◆ onWrite()

void xrpl::peer_finder::Counts::onWrite ( beast::PropertyStream::Map & map) const

Output statistics.

Definition at line 233 of file Counts.h.

◆ stateString()

std::string xrpl::peer_finder::Counts::stateString ( ) const
nodiscard

Records the state for diagnostics.

Definition at line 249 of file Counts.h.

◆ adjustCounter()

template<typename T>
void xrpl::peer_finder::Counts::adjustCounter ( T & counter,
CountAdjustment dir )
staticprivate

Increments or decrements a counter based on the adjustment direction.

Definition at line 264 of file Counts.h.

◆ adjust()

void xrpl::peer_finder::Counts::adjust ( Slot const & s,
CountAdjustment const dir )
private

Definition at line 286 of file Counts.h.

Member Data Documentation

◆ attempts_

int xrpl::peer_finder::Counts::attempts_ {0}
private

Outbound connection attempts.

Definition at line 344 of file Counts.h.

◆ active_

std::size_t xrpl::peer_finder::Counts::active_ {0}
private

Active connections, including fixed and reserved.

Definition at line 349 of file Counts.h.

◆ inMax_

std::size_t xrpl::peer_finder::Counts::inMax_ {0}
private

Total number of inbound slots.

Definition at line 354 of file Counts.h.

◆ inActive_

std::size_t xrpl::peer_finder::Counts::inActive_ {0}
private

Number of inbound slots assigned to active peers.

Definition at line 359 of file Counts.h.

◆ outMax_

std::size_t xrpl::peer_finder::Counts::outMax_ {0}
private

Maximum desired outbound slots.

Definition at line 364 of file Counts.h.

◆ outActive_

std::size_t xrpl::peer_finder::Counts::outActive_ {0}
private

Active outbound slots.

Definition at line 369 of file Counts.h.

◆ fixed_

std::size_t xrpl::peer_finder::Counts::fixed_ {0}
private

Fixed connections.

Definition at line 374 of file Counts.h.

◆ fixedActive_

std::size_t xrpl::peer_finder::Counts::fixedActive_ {0}
private

Active fixed connections.

Definition at line 379 of file Counts.h.

◆ reserved_

std::size_t xrpl::peer_finder::Counts::reserved_ {0}
private

Reserved connections.

Definition at line 384 of file Counts.h.

◆ acceptCount_

int xrpl::peer_finder::Counts::acceptCount_ {0}
private

Definition at line 388 of file Counts.h.

◆ closingCount_

int xrpl::peer_finder::Counts::closingCount_ {0}
private

Definition at line 391 of file Counts.h.