rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ripple::PeerFinder::Logic< Checker > Class Template Reference

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

#include <Logic.h>

Collaboration diagram for ripple::PeerFinder::Logic< Checker >:
Collaboration graph
[legend]

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 const &name, beast::IP::Endpoint const &ep)
 
void addFixedPeer (std::string const &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, Resultnew_inbound_slot (beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint)
 
std::pair< SlotImp::ptr, Resultnew_outbound_slot (beast::IP::Endpoint const &remote_endpoint)
 
bool onConnected (SlotImp::ptr const &slot, beast::IP::Endpoint const &local_endpoint)
 
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 once_per_second ()
 
void preprocess (SlotImp::ptr const &slot, Endpoints &list)
 
void on_endpoints (SlotImp::ptr const &slot, Endpoints list)
 
void remove (SlotImp::ptr const &slot)
 
void on_closed (SlotImp::ptr const &slot)
 
void on_failure (SlotImp::ptr const &slot)
 
template<class FwdIter >
void onRedirects (FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const &remote_address)
 
bool fixed (beast::IP::Endpoint const &endpoint) const
 
bool fixed (beast::IP::Address const &address) const
 
template<class Container >
void get_fixed (std::size_t needed, Container &c, typename 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 is_valid_address (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 m_journal
 
clock_typem_clock
 
Storem_store
 
Checkerm_checker
 
std::recursive_mutex lock_
 
bool stopping_ = false
 
std::shared_ptr< SourcefetchSource_
 
Config config_
 
Counts counts_
 
std::map< beast::IP::Endpoint, Fixedfixed_
 
Livecache livecache_
 
Bootcache bootcache_
 
Slots slots_
 
std::multiset< beast::IP::AddressconnectedAddresses_
 
std::set< PublicKeykeys_
 
std::vector< std::shared_ptr< Source > > m_sources
 
clock_type::time_point m_whenBroadcast
 
ConnectHandouts::Squelches m_squelches
 

Detailed Description

template<class Checker>
class ripple::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 35 of file src/xrpld/peerfinder/detail/Logic.h.

Member Typedef Documentation

◆ Slots

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

Constructor & Destructor Documentation

◆ Logic()

template<class Checker >
ripple::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 ripple::PeerFinder::Logic< Checker >::load ( )

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

◆ stop()

template<class Checker >
void ripple::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 125 of file src/xrpld/peerfinder/detail/Logic.h.

◆ config() [1/2]

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

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

◆ config() [2/2]

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

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

◆ addFixedPeer() [1/2]

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

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

◆ addFixedPeer() [2/2]

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

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

◆ checkComplete()

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

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

◆ new_inbound_slot()

template<class Checker >
std::pair< SlotImp::ptr, Result > ripple::PeerFinder::Logic< Checker >::new_inbound_slot ( beast::IP::Endpoint const &  local_endpoint,
beast::IP::Endpoint const &  remote_endpoint 
)

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

◆ new_outbound_slot()

template<class Checker >
std::pair< SlotImp::ptr, Result > ripple::PeerFinder::Logic< Checker >::new_outbound_slot ( beast::IP::Endpoint const &  remote_endpoint)

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

◆ onConnected()

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

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

◆ activate()

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

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

◆ redirect()

template<class Checker >
std::vector< Endpoint > ripple::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 462 of file src/xrpld/peerfinder/detail/Logic.h.

◆ autoconnect()

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

Create new outbound connection attempts as needed.

This implements PeerFinder's "Outbound Connection Strategy"

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

◆ buildEndpointsForPeers()

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

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

◆ once_per_second()

template<class Checker >
void ripple::PeerFinder::Logic< Checker >::once_per_second ( )

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

◆ preprocess()

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

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

◆ on_endpoints()

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

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

◆ remove()

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

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

◆ on_closed()

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

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

◆ on_failure()

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

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

◆ onRedirects()

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

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

◆ fixed() [1/2]

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

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

◆ fixed() [2/2]

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

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

◆ get_fixed()

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

Adds eligible Fixed addresses for outbound attempts.

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

◆ addStaticSource()

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

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

◆ addSource()

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

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

◆ addBootcacheAddresses()

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

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

◆ fetch()

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

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

◆ is_valid_address()

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

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

◆ writeSlots()

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

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

◆ onWrite()

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

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

◆ counts()

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

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

◆ stateString()

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

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

Member Data Documentation

◆ m_journal

template<class Checker >
beast::Journal ripple::PeerFinder::Logic< Checker >::m_journal

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

◆ m_clock

template<class Checker >
clock_type& ripple::PeerFinder::Logic< Checker >::m_clock

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

◆ m_store

template<class Checker >
Store& ripple::PeerFinder::Logic< Checker >::m_store

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

◆ m_checker

template<class Checker >
Checker& ripple::PeerFinder::Logic< Checker >::m_checker

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

◆ lock_

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

◆ stopping_

template<class Checker >
bool ripple::PeerFinder::Logic< Checker >::stopping_ = false

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

◆ fetchSource_

template<class Checker >
std::shared_ptr<Source> ripple::PeerFinder::Logic< Checker >::fetchSource_

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

◆ config_

template<class Checker >
Config ripple::PeerFinder::Logic< Checker >::config_

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

◆ counts_

template<class Checker >
Counts ripple::PeerFinder::Logic< Checker >::counts_

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

◆ fixed_

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

◆ livecache_

template<class Checker >
Livecache ripple::PeerFinder::Logic< Checker >::livecache_

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

◆ bootcache_

template<class Checker >
Bootcache ripple::PeerFinder::Logic< Checker >::bootcache_

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

◆ slots_

template<class Checker >
Slots ripple::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> ripple::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.

◆ m_sources

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

◆ m_whenBroadcast

template<class Checker >
clock_type::time_point ripple::PeerFinder::Logic< Checker >::m_whenBroadcast

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

◆ m_squelches

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