1#ifndef XRPL_PEERFINDER_COUNTS_H_INCLUDED
2#define XRPL_PEERFINDER_COUNTS_H_INCLUDED
4#include <xrpld/peerfinder/PeerfinderManager.h>
5#include <xrpld/peerfinder/Slot.h>
6#include <xrpld/peerfinder/detail/Tuning.h>
8#include <xrpl/basics/random.h>
56 "xrpl::PeerFinder::Counts::can_activate : valid input state");
249 "xrpl::PeerFinder::Counts::adjust : input is inbound");
257 "xrpl::PeerFinder::Counts::adjust : input is not "
282 "xrpl::PeerFinder::Counts::adjust : invalid input state");
Manages the count of available connections for the various slots.
int inboundSlotsFree() const
Returns the number of unused inbound slots.
void onWrite(beast::PropertyStream::Map &map)
Output statistics.
int outboundSlotsFree() const
Returns the number of unused outbound slots.
std::size_t m_in_active
Number of inbound slots assigned to active peers.
int connectCount() const
Returns the number of connection attempts currently active.
void remove(Slot const &s)
Removes the slot state and properties from the slot counts.
std::size_t attempts() const
Returns the number of outbound connection attempts.
int closingCount() const
Returns the number of connections that are gracefully closing.
std::size_t m_active
Active connections, including fixed and reserved.
int m_attempts
Outbound connection attempts.
int out_max() const
Returns the total number of outbound slots.
int inboundActive() const
Returns the number of inbound peers assigned an open slot.
std::size_t m_fixed
Fixed connections.
bool can_activate(Slot const &s) const
Returns true if the slot can become active.
void adjust(Slot const &s, int const n)
int acceptCount() const
Returns the number of accepted connections that haven't handshaked.
std::string state_string() const
Records the state for diagnostics.
std::size_t m_fixed_active
Active fixed connections.
int totalActive() const
Returns the total number of active peers excluding fixed peers.
int in_max() const
Returns the total number of inbound slots.
std::size_t fixed_active() const
Returns the number of active fixed connections.
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 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 m_out_active
Active outbound slots.
int out_active() const
Returns the number of outbound peers assigned an open slot.
std::size_t m_reserved
Reserved connections.
std::size_t m_out_max
Maximum desired outbound slots.
std::size_t attempts_needed() const
Returns the number of attempts needed to bring us to the max.
std::size_t m_in_max
Total number of inbound 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.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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.