xrpld
Loading...
Searching...
No Matches
xrpl::PeerFinder::Logic< Checker > Class Template Reference

The Logic for maintaining the list of Slot addresses. More...

#include <Logic.h>

Collaboration diagram for xrpl::PeerFinder::Logic< Checker >:

Public Types

using Slots = std::map<beast::IP::Endpoint, std::shared_ptr<SlotImp>>

Public Member Functions

 Logic (clock_type &clock, Store &store, Checker &checker, beast::Journal journal)
void load ()
void stop ()
 Stop the logic.
void config (Config const &c)
Config config ()
void addFixedPeer (std::string_view name, beast::IP::Endpoint const &ep)
void addFixedPeer (std::string_view name, std::vector< beast::IP::Endpoint > const &addresses)
void checkComplete (beast::IP::Endpoint const &remoteAddress, beast::IP::Endpoint const &checkedAddress, boost::system::error_code ec)
std::pair< SlotImp::ptr, ResultnewInboundSlot (beast::IP::Endpoint const &localEndpoint, beast::IP::Endpoint const &remoteEndpoint)
std::pair< SlotImp::ptr, ResultnewOutboundSlot (beast::IP::Endpoint const &remoteEndpoint)
bool onConnected (SlotImp::ptr const &slot, beast::IP::Endpoint const &localEndpoint)
Result activate (SlotImp::ptr const &slot, PublicKey const &key, bool reserved)
std::vector< Endpointredirect (SlotImp::ptr const &slot)
 Return a list of addresses suitable for redirection.
std::vector< beast::IP::Endpointautoconnect ()
 Create new outbound connection attempts as needed.
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers ()
void oncePerSecond ()
void preprocess (SlotImp::ptr const &slot, Endpoints &list)
void onEndpoints (SlotImp::ptr const &slot, Endpoints list)
void remove (SlotImp::ptr const &slot)
void onClosed (SlotImp::ptr const &slot)
void onFailure (SlotImp::ptr const &slot)
template<class FwdIter>
void onRedirects (FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const &remoteAddress)
bool fixed (beast::IP::Endpoint const &endpoint) const
bool fixed (beast::IP::Address const &address) const
template<class Container>
void getFixed (std::size_t needed, Container &c, ConnectHandouts::Squelches &squelches)
 Adds eligible Fixed addresses for outbound attempts.
void addStaticSource (std::shared_ptr< Source > const &source)
void addSource (std::shared_ptr< Source > const &source)
int addBootcacheAddresses (IPAddresses const &list)
void fetch (std::shared_ptr< Source > const &source)
bool isValidAddress (beast::IP::Endpoint const &address)
void writeSlots (beast::PropertyStream::Set &set, Slots const &slots)
void onWrite (beast::PropertyStream::Map &map)
Counts const & counts () const

Static Public Member Functions

static std::string stateString (Slot::State state)

Public Attributes

beast::Journal journal
clock_typeclock
Storestore
Checkerchecker
std::recursive_mutex lock
bool stopping = false
std::shared_ptr< SourcefetchSource
Livecache livecache
Bootcache bootcache
Slots slots
std::multiset< beast::IP::AddressconnectedAddresses
std::set< PublicKeykeys
std::vector< std::shared_ptr< Source > > sources
clock_type::time_point whenBroadcast
ConnectHandouts::Squelches squelches

Private Attributes

Config config_
Counts counts_
std::map< beast::IP::Endpoint, Fixedfixed_

Detailed Description

template<class Checker>
class xrpl::PeerFinder::Logic< Checker >

The Logic for maintaining the list of Slot addresses.

We keep this in a separate class so it can be instantiated for unit tests.

Definition at line 33 of file src/xrpld/peerfinder/detail/Logic.h.

Member Typedef Documentation

◆ Slots

Constructor & Destructor Documentation

◆ Logic()

template<class Checker>
xrpl::PeerFinder::Logic< Checker >::Logic ( clock_type & clock,
Store & store,
Checker & checker,
beast::Journal journal )

Definition at line 92 of file src/xrpld/peerfinder/detail/Logic.h.

Member Function Documentation

◆ load()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::load ( )

Definition at line 108 of file src/xrpld/peerfinder/detail/Logic.h.

◆ stop()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::stop ( )

Stop the logic.

This will cancel the current fetch and set the stopping flag to true to prevent further fetches. Thread safety: Safe to call from any thread.

Definition at line 121 of file src/xrpld/peerfinder/detail/Logic.h.

◆ config() [1/2]

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::config ( Config const & c)

Definition at line 136 of file src/xrpld/peerfinder/detail/Logic.h.

◆ config() [2/2]

template<class Checker>
Config xrpl::PeerFinder::Logic< Checker >::config ( )

Definition at line 144 of file src/xrpld/peerfinder/detail/Logic.h.

◆ addFixedPeer() [1/2]

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::addFixedPeer ( std::string_view name,
beast::IP::Endpoint const & ep )

Definition at line 151 of file src/xrpld/peerfinder/detail/Logic.h.

◆ addFixedPeer() [2/2]

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::addFixedPeer ( std::string_view name,
std::vector< beast::IP::Endpoint > const & addresses )

Definition at line 157 of file src/xrpld/peerfinder/detail/Logic.h.

◆ checkComplete()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::checkComplete ( beast::IP::Endpoint const & remoteAddress,
beast::IP::Endpoint const & checkedAddress,
boost::system::error_code ec )

Definition at line 193 of file src/xrpld/peerfinder/detail/Logic.h.

◆ newInboundSlot()

template<class Checker>
std::pair< SlotImp::ptr, Result > xrpl::PeerFinder::Logic< Checker >::newInboundSlot ( beast::IP::Endpoint const & localEndpoint,
beast::IP::Endpoint const & remoteEndpoint )

Definition at line 236 of file src/xrpld/peerfinder/detail/Logic.h.

◆ newOutboundSlot()

template<class Checker>
std::pair< SlotImp::ptr, Result > xrpl::PeerFinder::Logic< Checker >::newOutboundSlot ( beast::IP::Endpoint const & remoteEndpoint)

Definition at line 287 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onConnected()

template<class Checker>
bool xrpl::PeerFinder::Logic< Checker >::onConnected ( SlotImp::ptr const & slot,
beast::IP::Endpoint const & localEndpoint )

Definition at line 323 of file src/xrpld/peerfinder/detail/Logic.h.

◆ activate()

template<class Checker>
Result xrpl::PeerFinder::Logic< Checker >::activate ( SlotImp::ptr const & slot,
PublicKey const & key,
bool reserved )

Definition at line 361 of file src/xrpld/peerfinder/detail/Logic.h.

◆ redirect()

template<class Checker>
std::vector< Endpoint > xrpl::PeerFinder::Logic< Checker >::redirect ( SlotImp::ptr const & slot)

Return a list of addresses suitable for redirection.

This is a legacy function, redirects should be returned in the HTTP handshake and not via TMEndpoints.

Definition at line 440 of file src/xrpld/peerfinder/detail/Logic.h.

◆ autoconnect()

template<class Checker>
std::vector< beast::IP::Endpoint > xrpl::PeerFinder::Logic< Checker >::autoconnect ( )

Create new outbound connection attempts as needed.

This implements PeerFinder's "Outbound Connection Strategy"

Definition at line 456 of file src/xrpld/peerfinder/detail/Logic.h.

◆ buildEndpointsForPeers()

template<class Checker>
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > xrpl::PeerFinder::Logic< Checker >::buildEndpointsForPeers ( )

Definition at line 561 of file src/xrpld/peerfinder/detail/Logic.h.

◆ oncePerSecond()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::oncePerSecond ( )

Definition at line 641 of file src/xrpld/peerfinder/detail/Logic.h.

◆ preprocess()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::preprocess ( SlotImp::ptr const & slot,
Endpoints & list )

Definition at line 662 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onEndpoints()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::onEndpoints ( SlotImp::ptr const & slot,
Endpoints list )

Definition at line 726 of file src/xrpld/peerfinder/detail/Logic.h.

◆ remove()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::remove ( SlotImp::ptr const & slot)

Definition at line 823 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onClosed()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::onClosed ( SlotImp::ptr const & slot)

Definition at line 871 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onFailure()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::onFailure ( SlotImp::ptr const & slot)

Definition at line 931 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onRedirects()

template<class Checker>
template<class FwdIter>
void xrpl::PeerFinder::Logic< Checker >::onRedirects ( FwdIter first,
FwdIter last,
boost::asio::ip::tcp::endpoint const & remoteAddress )

Definition at line 1201 of file src/xrpld/peerfinder/detail/Logic.h.

◆ fixed() [1/2]

template<class Checker>
bool xrpl::PeerFinder::Logic< Checker >::fixed ( beast::IP::Endpoint const & endpoint) const

Definition at line 948 of file src/xrpld/peerfinder/detail/Logic.h.

◆ fixed() [2/2]

template<class Checker>
bool xrpl::PeerFinder::Logic< Checker >::fixed ( beast::IP::Address const & address) const

Definition at line 962 of file src/xrpld/peerfinder/detail/Logic.h.

◆ getFixed()

template<class Checker>
template<class Container>
void xrpl::PeerFinder::Logic< Checker >::getFixed ( std::size_t needed,
Container & c,
ConnectHandouts::Squelches & squelches )

Adds eligible Fixed addresses for outbound attempts.

Definition at line 981 of file src/xrpld/peerfinder/detail/Logic.h.

◆ addStaticSource()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::addStaticSource ( std::shared_ptr< Source > const & source)

Definition at line 1002 of file src/xrpld/peerfinder/detail/Logic.h.

◆ addSource()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::addSource ( std::shared_ptr< Source > const & source)

Definition at line 1008 of file src/xrpld/peerfinder/detail/Logic.h.

◆ addBootcacheAddresses()

template<class Checker>
int xrpl::PeerFinder::Logic< Checker >::addBootcacheAddresses ( IPAddresses const & list)

Definition at line 1023 of file src/xrpld/peerfinder/detail/Logic.h.

◆ fetch()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::fetch ( std::shared_ptr< Source > const & source)

Definition at line 1037 of file src/xrpld/peerfinder/detail/Logic.h.

◆ isValidAddress()

template<class Checker>
bool xrpl::PeerFinder::Logic< Checker >::isValidAddress ( beast::IP::Endpoint const & address)

Definition at line 1085 of file src/xrpld/peerfinder/detail/Logic.h.

◆ writeSlots()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::writeSlots ( beast::PropertyStream::Set & set,
Slots const & slots )

Definition at line 1105 of file src/xrpld/peerfinder/detail/Logic.h.

◆ onWrite()

template<class Checker>
void xrpl::PeerFinder::Logic< Checker >::onWrite ( beast::PropertyStream::Map & map)

Definition at line 1126 of file src/xrpld/peerfinder/detail/Logic.h.

◆ counts()

template<class Checker>
Counts const & xrpl::PeerFinder::Logic< Checker >::counts ( ) const

Definition at line 1169 of file src/xrpld/peerfinder/detail/Logic.h.

◆ stateString()

template<class Checker>
std::string xrpl::PeerFinder::Logic< Checker >::stateString ( Slot::State state)
static

Definition at line 1175 of file src/xrpld/peerfinder/detail/Logic.h.

Member Data Documentation

◆ journal

Definition at line 41 of file src/xrpld/peerfinder/detail/Logic.h.

◆ clock

template<class Checker>
clock_type& xrpl::PeerFinder::Logic< Checker >::clock

Definition at line 42 of file src/xrpld/peerfinder/detail/Logic.h.

◆ store

template<class Checker>
Store& xrpl::PeerFinder::Logic< Checker >::store

Definition at line 43 of file src/xrpld/peerfinder/detail/Logic.h.

◆ checker

template<class Checker>
Checker& xrpl::PeerFinder::Logic< Checker >::checker

Definition at line 44 of file src/xrpld/peerfinder/detail/Logic.h.

◆ lock

◆ stopping

template<class Checker>
bool xrpl::PeerFinder::Logic< Checker >::stopping = false

Definition at line 49 of file src/xrpld/peerfinder/detail/Logic.h.

◆ fetchSource

template<class Checker>
std::shared_ptr<Source> xrpl::PeerFinder::Logic< Checker >::fetchSource

Definition at line 53 of file src/xrpld/peerfinder/detail/Logic.h.

◆ config_

template<class Checker>
Config xrpl::PeerFinder::Logic< Checker >::config_
private

Definition at line 57 of file src/xrpld/peerfinder/detail/Logic.h.

◆ counts_

template<class Checker>
Counts xrpl::PeerFinder::Logic< Checker >::counts_
private

Definition at line 60 of file src/xrpld/peerfinder/detail/Logic.h.

◆ fixed_

Definition at line 63 of file src/xrpld/peerfinder/detail/Logic.h.

◆ livecache

template<class Checker>
Livecache xrpl::PeerFinder::Logic< Checker >::livecache

Definition at line 67 of file src/xrpld/peerfinder/detail/Logic.h.

◆ bootcache

template<class Checker>
Bootcache xrpl::PeerFinder::Logic< Checker >::bootcache

Definition at line 70 of file src/xrpld/peerfinder/detail/Logic.h.

◆ slots

template<class Checker>
Slots xrpl::PeerFinder::Logic< Checker >::slots

Definition at line 73 of file src/xrpld/peerfinder/detail/Logic.h.

◆ connectedAddresses

template<class Checker>
std::multiset<beast::IP::Address> xrpl::PeerFinder::Logic< Checker >::connectedAddresses

Definition at line 78 of file src/xrpld/peerfinder/detail/Logic.h.

◆ keys

Definition at line 81 of file src/xrpld/peerfinder/detail/Logic.h.

◆ sources

◆ whenBroadcast

Definition at line 86 of file src/xrpld/peerfinder/detail/Logic.h.

◆ squelches