3#include <xrpl/beast/utility/PropertyStream.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/peerfinder/Config.h>
6#include <xrpl/peerfinder/Slot.h>
7#include <xrpl/peerfinder/detail/Tuning.h>
53 "xrpl::peer_finder::Counts::can_activate : valid input state");
262 template <
typename T>
288 int const n =
static_cast<int>(dir);
298 XRPL_ASSERT(s.
inbound(),
"xrpl::peer_finder::Counts::adjust : input is inbound");
306 "xrpl::peer_finder::Counts::adjust : input is not "
334 UNREACHABLE(
"xrpl::peer_finder::Counts::adjust : invalid input state");
Manages the count of available connections for the various slots.
void remove(Slot const &s)
Removes the slot state and properties from the slot counts.
std::size_t fixed_
Fixed connections.
int inboundActive() const
Returns the number of inbound peers assigned an open slot.
void adjust(Slot const &s, CountAdjustment const dir)
std::size_t outMax_
Maximum desired outbound slots.
static void adjustCounter(T &counter, CountAdjustment dir)
Increments or decrements a counter based on the adjustment direction.
int closingCount() const
Returns the number of connections that are gracefully closing.
std::size_t fixedActive() const
Returns the number of active fixed connections.
void onWrite(beast::PropertyStream::Map &map) const
Output statistics.
int outMax() const
Returns the total number of outbound slots.
bool canActivate(Slot const &s) const
Returns true if the slot can become active.
std::size_t inActive_
Number of inbound slots assigned to active peers.
bool isConnectedToNetwork() const
Returns true if the slot logic considers us "connected" to the network.
std::size_t reserved_
Reserved connections.
std::size_t outActive_
Active outbound slots.
void onConfig(Config const &config)
Called when the config is set or changed.
std::string stateString() const
Records the state for diagnostics.
int acceptCount() const
Returns the number of accepted connections that haven't handshaked.
int outActive() const
Returns the number of outbound peers assigned an open slot.
int inMax() const
Returns the total number of inbound slots.
int totalActive() const
Returns the total number of active peers excluding fixed peers.
std::size_t inMax_
Total number of inbound slots.
std::size_t attempts() const
Returns the number of outbound connection attempts.
int inboundSlotsFree() const
Returns the number of unused inbound slots.
void add(Slot const &s)
Adds the slot state and properties to the slot counts.
int outboundSlotsFree() const
Returns the number of unused outbound slots.
std::size_t fixedActive_
Active fixed connections.
std::size_t attemptsNeeded() const
Returns the number of attempts needed to bring us to the max.
int attempts_
Outbound connection attempts.
std::size_t fixed() const
Returns the number of fixed connections.
int connectCount() const
Returns the number of connection attempts currently active.
std::size_t active_
Active connections, including fixed and reserved.
Properties and state associated with a peer to peer overlay connection.
virtual State state() const =0
Returns the state of the connection.
virtual bool fixed() const =0
Returns true if this is a fixed connection.
virtual bool inbound() const =0
Returns true if this is an inbound connection.
virtual bool reserved() const =0
Returns true if this is a reserved connection.
static constexpr auto kMaxConnectAttempts
Maximum number of simultaneous connection attempts.
CountAdjustment
Direction of a slot count adjustment.
PeerFinder configuration settings.
std::size_t outPeers
The number of automatic outbound connections to maintain.
bool wantIncoming
true if we want to accept incoming connections.
std::size_t inPeers
The number of automatic inbound connections to maintain.