20 #include <ripple/peerfinder/PeerfinderManager.h>
21 #include <ripple/peerfinder/impl/Checker.h>
22 #include <ripple/peerfinder/impl/Logic.h>
23 #include <ripple/peerfinder/impl/SourceStrings.h>
24 #include <ripple/peerfinder/impl/StoreSqdb.h>
25 #include <boost/asio/io_service.hpp>
26 #include <boost/utility/in_place_factory.hpp>
32 namespace PeerFinder {
49 boost::asio::io_service& io_service,
143 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
150 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
157 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
163 boost::asio::ip::tcp::endpoint
const& remote_address,
176 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
184 bool reserved)
override
186 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
193 SlotImp::ptr impl(std::dynamic_pointer_cast<SlotImp>(slot));
237 template <
class Handler>
239 Handler
const& handler,
241 :
hook(collector->make_hook(handler))
243 collector->make_gauge(
"Peer_Finder",
"Active_Inbound_Peers"))
245 collector->make_gauge(
"Peer_Finder",
"Active_Outbound_Peers"))
274 boost::asio::io_service& io_service,
280 return std::make_unique<ManagerImp>(
281 io_service, clock, journal, config, collector);
std::string const & name() const
Returns the name of this source.
Logic< decltype(checker_)> m_logic
int inboundActive() const
Returns the number of inbound peers assigned an open slot.
The Logic for maintaining the list of Slot addresses.
Database persistence for PeerFinder using SQLite.
SlotImp::ptr new_outbound_slot(beast::IP::Endpoint const &remote_endpoint)
void on_failure(SlotImp::ptr const &slot)
bool onConnected(std::shared_ptr< Slot > const &slot, beast::IP::Endpoint const &local_endpoint) override
Called when an outbound connection attempt succeeds.
void onRedirects(FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const &remote_address)
std::optional< boost::asio::io_service::work > work_
beast::insight::Gauge activeOutboundPeers
A static or dynamic source of peer addresses.
void addFallbackURL(std::string const &name, std::string const &url)
std::vector< beast::IP::Endpoint > autoconnect() override
Return a set of addresses we should connect to.
std::vector< Endpoint > redirect(std::shared_ptr< Slot > const &slot) override
Returns a set of endpoints suitable for redirection.
BasicConfig const & m_config
bool onConnected(SlotImp::ptr const &slot, beast::IP::Endpoint const &local_endpoint)
void addFixedPeer(std::string const &name, std::vector< beast::IP::Endpoint > const &addresses) override
Add a peer that should always be connected.
void stop() override
Transition to the stopped state, synchronously.
void on_closed(std::shared_ptr< Slot > const &slot) override
Called when the slot is closed.
void addStaticSource(std::shared_ptr< Source > const &source)
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers()
std::vector< Endpoint > redirect(SlotImp::ptr const &slot)
Return a list of addresses suitable for redirection.
void onWrite(beast::PropertyStream::Map &map)
int out_active() const
Returns the number of outbound peers assigned an open slot.
void start() override
Transition to the started state, synchronously.
std::unique_ptr< Manager > make_Manager(boost::asio::io_service &io_service, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Create a new Manager.
void stop()
Stop the logic.
boost::asio::io_service & io_service_
std::vector< beast::IP::Endpoint > autoconnect()
Create new outbound connection attempts as needed.
void addFixedPeer(std::string const &name, beast::IP::Endpoint const &ep)
A generic endpoint for log messages.
void stop()
Stop the service.
Result activate(SlotImp::ptr const &slot, PublicKey const &key, bool reserved)
Abstract interface to a clock.
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)
A metric for measuring an integral value.
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers() override
void open(BasicConfig const &config)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void on_failure(std::shared_ptr< Slot > const &slot) override
Called when an outbound connection is deemed to have failed.
void once_per_second() override
Perform periodic activity.
Config config() override
Returns the configuration for the manager.
void addFallbackStrings(std::string const &name, std::vector< std::string > const &strings) override
Add a set of strings as fallback IP::Endpoint sources.
SlotImp::ptr new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint)
beast::insight::Hook hook
Checker< boost::asio::ip::tcp > checker_
void on_endpoints(std::shared_ptr< Slot > const &slot, Endpoints const &endpoints) override
Called when mtENDPOINTS is received.
A version-independent IP address and port combination.
void onWrite(beast::PropertyStream::Map &map) override
Subclass override.
PeerFinder configuration settings.
void on_closed(SlotImp::ptr const &slot)
void config(Config const &c)
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.
beast::insight::Gauge activeInboundPeers
static std::shared_ptr< Source > New(std::string const &name, Strings const &strings)
void setConfig(Config const &config) override
Set the configuration for the manager.
A reference to a handler for performing polled collection.
Holds unparsed configuration information.
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.
std::shared_ptr< Slot > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint) override
Create a new outbound slot with the specified remote endpoint.
ManagerImp(boost::asio::io_service &io_service, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
std::shared_ptr< Slot > 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 on_endpoints(SlotImp::ptr const &slot, Endpoints list)
Result
Possible results from activating a slot.