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