1#include <xrpld/peerfinder/PeerfinderManager.h>
2#include <xrpld/peerfinder/detail/Checker.h>
3#include <xrpld/peerfinder/detail/Logic.h>
4#include <xrpld/peerfinder/detail/SourceStrings.h>
5#include <xrpld/peerfinder/detail/StoreSqdb.h>
7#include <boost/asio/executor_work_guard.hpp>
8#include <boost/asio/io_context.hpp>
21 boost::asio::io_context::executor_type>>
33 boost::asio::io_context& io_context,
147 boost::asio::ip::tcp::endpoint
const& remote_address,
168 bool reserved)
override
221 template <
class Handler>
223 Handler
const& handler,
225 :
hook(collector->make_hook(handler))
227 collector->make_gauge(
"Peer_Finder",
"Active_Inbound_Peers"))
229 collector->make_gauge(
"Peer_Finder",
"Active_Outbound_Peers"))
258 boost::asio::io_context& io_context,
265 io_context, clock, journal, config, collector);
A version-independent IP address and port combination.
A generic endpoint for log messages.
std::string const & name() const
Returns the name of this source.
A metric for measuring an integral value.
A reference to a handler for performing polled collection.
Holds unparsed configuration information.
Tests remote listening sockets to make sure they are connectible.
void stop()
Stop the service.
int out_active() const
Returns the number of outbound peers assigned an open slot.
int inboundActive() const
Returns the number of inbound peers assigned an open slot.
The Logic for maintaining the list of Slot addresses.
void stop()
Stop the logic.
void onWrite(beast::PropertyStream::Map &map)
bool onConnected(SlotImp::ptr const &slot, beast::IP::Endpoint const &local_endpoint)
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers()
void on_closed(SlotImp::ptr const &slot)
void on_failure(SlotImp::ptr const &slot)
Result activate(SlotImp::ptr const &slot, PublicKey const &key, bool reserved)
std::pair< SlotImp::ptr, Result > new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint)
std::vector< beast::IP::Endpoint > autoconnect()
Create new outbound connection attempts as needed.
void onRedirects(FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const &remote_address)
void on_endpoints(SlotImp::ptr const &slot, Endpoints list)
void addStaticSource(std::shared_ptr< Source > const &source)
std::pair< SlotImp::ptr, Result > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint)
void addFixedPeer(std::string const &name, beast::IP::Endpoint const &ep)
std::vector< Endpoint > redirect(SlotImp::ptr const &slot)
Return a list of addresses suitable for redirection.
void config(Config const &c)
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers() override
void addFixedPeer(std::string const &name, std::vector< beast::IP::Endpoint > const &addresses) override
Add a peer that should always be connected.
void on_closed(std::shared_ptr< Slot > const &slot) override
Called when the slot is closed.
void addFallbackStrings(std::string const &name, std::vector< std::string > const &strings) override
Add a set of strings as fallback IP::Endpoint sources.
std::pair< std::shared_ptr< Slot >, Result > new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint) override
Add a URL as a fallback location to obtain IP::Endpoint sources.
void stop() override
Transition to the stopped state, synchronously.
std::vector< beast::IP::Endpoint > autoconnect() override
Return a set of addresses we should connect to.
std::pair< std::shared_ptr< Slot >, Result > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint) override
Create a new outbound slot with the specified remote endpoint.
void on_failure(std::shared_ptr< Slot > const &slot) override
Called when an outbound connection is deemed to have failed.
Checker< boost::asio::ip::tcp > checker_
bool onConnected(std::shared_ptr< Slot > const &slot, beast::IP::Endpoint const &local_endpoint) override
Called when an outbound connection attempt succeeds.
ManagerImp(boost::asio::io_context &io_context, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
boost::asio::io_context & io_context_
void onWrite(beast::PropertyStream::Map &map) override
Subclass override.
void once_per_second() override
Perform periodic activity.
void addFallbackURL(std::string const &name, std::string const &url)
Logic< decltype(checker_)> m_logic
void setConfig(Config const &config) override
Set the configuration for the manager.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
BasicConfig const & m_config
Config config() override
Returns the configuration for the manager.
void onRedirects(boost::asio::ip::tcp::endpoint const &remote_address, std::vector< boost::asio::ip::tcp::endpoint > const &eps) override
Called when we received redirect IPs from a busy peer.
std::vector< Endpoint > redirect(std::shared_ptr< Slot > const &slot) override
Returns a set of endpoints suitable for redirection.
void on_endpoints(std::shared_ptr< Slot > const &slot, Endpoints const &endpoints) override
Called when mtENDPOINTS is received.
void start() override
Transition to the started state, synchronously.
Result activate(std::shared_ptr< Slot > const &slot, PublicKey const &key, bool reserved) override
Request an active slot type.
Maintains a set of IP addresses used for getting into the network.
static std::shared_ptr< Source > New(std::string const &name, Strings const &strings)
A static or dynamic source of peer addresses.
Database persistence for PeerFinder using SQLite.
void open(BasicConfig const &config)
std::unique_ptr< Manager > make_Manager(boost::asio::io_context &io_context, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Create a new Manager.
Result
Possible results from activating a slot.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
PeerFinder configuration settings.
beast::insight::Gauge activeOutboundPeers
beast::insight::Gauge activeInboundPeers
beast::insight::Hook hook
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)