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 <ripple/core/SociDB.h>
26 #include <boost/asio/io_service.hpp>
27 #include <boost/optional.hpp>
28 #include <boost/utility/in_place_factory.hpp>
33 namespace PeerFinder {
40 boost::optional <boost::asio::io_service::work>
work_;
52 boost::asio::io_service& io_service,
142 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
149 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
156 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
161 onRedirects (boost::asio::ip::tcp::endpoint
const& remote_address,
173 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
179 PublicKey const& key,
bool reserved)
override
181 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
188 SlotImp::ptr impl (std::dynamic_pointer_cast <SlotImp> (slot));
249 template <
class Handler>
251 Handler
const& handler,
253 :
hook (collector->make_hook (handler))
286 return std::make_unique<ManagerImp> (
287 parent, 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.
SociConfig is used when a client wants to delay opening a soci::session after parsing the config para...
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
The Logic for maintaining the list of Slot addresses.
Database persistence for PeerFinder using SQLite.
void open(SociConfig const &sociConfig)
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)
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.
void onStop() override
Override called when the stop notification is issued.
Provides an interface for starting and stopping.
void onPrepare() override
Override called during preparation.
bool onConnected(SlotImp::ptr const &slot, beast::IP::Endpoint const &local_endpoint)
Manager(Stoppable &parent)
ManagerImp(Stoppable &stoppable, boost::asio::io_service &io_service, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
void addFixedPeer(std::string const &name, std::vector< beast::IP::Endpoint > const &addresses) override
Add a peer that should always be connected.
std::unique_ptr< Manager > make_Manager(Stoppable &parent, 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 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 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
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 onStart() override
Override called during start.
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
boost::optional< boost::asio::io_service::work > work_
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.
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.