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

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

#include <Counts.h>

Collaboration diagram for xrpl::PeerFinder::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 15 of file Counts.h.

Member Function Documentation

◆ add()

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

Adds the slot state and properties to the slot counts.

Definition at line 20 of file Counts.h.

◆ remove()

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

Removes the slot state and properties from the slot counts.

Definition at line 27 of file Counts.h.

◆ canActivate()

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

Returns true if the slot can become active.

Definition at line 34 of file Counts.h.

◆ attemptsNeeded()

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

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

Definition at line 52 of file Counts.h.

◆ attempts()

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

Returns the number of outbound connection attempts.

Definition at line 61 of file Counts.h.

◆ outMax()

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

Returns the total number of outbound slots.

Definition at line 68 of file Counts.h.

◆ outActive()

int xrpl::PeerFinder::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 77 of file Counts.h.

◆ fixed()

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

Returns the number of fixed connections.

Definition at line 84 of file Counts.h.

◆ fixedActive()

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

Returns the number of active fixed connections.

Definition at line 91 of file Counts.h.

◆ onConfig()

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

Called when the config is set or changed.

Definition at line 100 of file Counts.h.

◆ acceptCount()

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

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

Definition at line 109 of file Counts.h.

◆ connectCount()

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

Returns the number of connection attempts currently active.

Definition at line 116 of file Counts.h.

◆ closingCount()

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

Returns the number of connections that are gracefully closing.

Definition at line 123 of file Counts.h.

◆ inMax()

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

Returns the total number of inbound slots.

Definition at line 130 of file Counts.h.

◆ inboundActive()

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

Returns the number of inbound peers assigned an open slot.

Definition at line 137 of file Counts.h.

◆ totalActive()

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

Returns the total number of active peers excluding fixed peers.

Definition at line 144 of file Counts.h.

◆ inboundSlotsFree()

int xrpl::PeerFinder::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 153 of file Counts.h.

◆ outboundSlotsFree()

int xrpl::PeerFinder::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 164 of file Counts.h.

◆ isConnectedToNetwork()

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

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

Definition at line 176 of file Counts.h.

◆ onWrite()

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

Output statistics.

Definition at line 189 of file Counts.h.

◆ stateString()

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

Records the state for diagnostics.

Definition at line 203 of file Counts.h.

◆ adjustCounter()

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

Increments or decrements a counter based on the adjustment direction.

Definition at line 216 of file Counts.h.

◆ adjust()

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

Definition at line 238 of file Counts.h.

Member Data Documentation

◆ attempts_

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

Outbound connection attempts.

Definition at line 294 of file Counts.h.

◆ active_

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

Active connections, including fixed and reserved.

Definition at line 297 of file Counts.h.

◆ inMax_

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

Total number of inbound slots.

Definition at line 300 of file Counts.h.

◆ inActive_

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

Number of inbound slots assigned to active peers.

Definition at line 303 of file Counts.h.

◆ outMax_

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

Maximum desired outbound slots.

Definition at line 306 of file Counts.h.

◆ outActive_

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

Active outbound slots.

Definition at line 309 of file Counts.h.

◆ fixed_

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

Fixed connections.

Definition at line 312 of file Counts.h.

◆ fixedActive_

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

Active fixed connections.

Definition at line 315 of file Counts.h.

◆ reserved_

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

Reserved connections.

Definition at line 318 of file Counts.h.

◆ acceptCount_

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

Definition at line 322 of file Counts.h.

◆ closingCount_

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

Definition at line 325 of file Counts.h.