rippled
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
ripple::PeerFinder::Bootcache Class Reference

Stores IP addresses useful for gaining initial connections. More...

Collaboration diagram for ripple::PeerFinder::Bootcache:
Collaboration graph
[legend]

Classes

class  Entry
 
struct  Transform
 

Public Types

using iterator = boost::transform_iterator< Transform, map_type::right_map::const_iterator >
 
using const_iterator = iterator
 

Public Member Functions

 Bootcache (Store &store, clock_type &clock, beast::Journal journal)
 
 ~Bootcache ()
 
bool empty () const
 Returns true if the cache is empty. More...
 
map_type::size_type size () const
 Returns the number of entries in the cache. More...
 
void load ()
 Load the persisted data from the Store into the container. More...
 
bool insert (beast::IP::Endpoint const &endpoint)
 Add a newly-learned address to the cache. More...
 
bool insertStatic (beast::IP::Endpoint const &endpoint)
 Add a staticallyconfigured address to the cache. More...
 
void on_success (beast::IP::Endpoint const &endpoint)
 Called when an outbound connection handshake completes. More...
 
void on_failure (beast::IP::Endpoint const &endpoint)
 Called when an outbound connection attempt fails to handshake. More...
 
void periodicActivity ()
 Stores the cache in the persistent database on a timer. More...
 
void onWrite (beast::PropertyStream::Map &map)
 Write the cache state to the property stream. More...
 
const_iterator begin () const
 IP::Endpoint iterators that traverse in decreasing valence. More...
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
void clear ()
 

Static Public Attributes

static constexpr int staticValence = 32
 

Private Types

using left_t = boost::bimaps::unordered_set_of< beast::IP::Endpoint, boost::hash< beast::IP::Endpoint >, ripple::equal_to< beast::IP::Endpoint > >
 
using right_t = boost::bimaps::multiset_of< Entry, ripple::less< Entry > >
 
using map_type = boost::bimap< left_t, right_t >
 
using value_type = map_type::value_type
 

Private Member Functions

void prune ()
 
void update ()
 
void checkUpdate ()
 
void flagForUpdate ()
 

Private Attributes

map_type m_map
 
Storem_store
 
clock_typem_clock
 
beast::Journal m_journal
 
clock_type::time_point m_whenUpdate
 
bool m_needsUpdate
 

Detailed Description

Stores IP addresses useful for gaining initial connections.

This is one of the caches that is consulted when additional outgoing connections are needed. Along with the address, each entry has this additional metadata:

Valence A signed integer which represents the number of successful consecutive connection attempts when positive, and the number of failed consecutive connection attempts when negative.

When choosing addresses from the boot cache for the purpose of establishing outgoing connections, addresses are ranked in decreasing order of high uptime, with valence as the tie breaker.

Definition at line 51 of file Bootcache.h.

Member Typedef Documentation

◆ left_t

Definition at line 88 of file Bootcache.h.

◆ right_t

using ripple::PeerFinder::Bootcache::right_t = boost::bimaps::multiset_of<Entry, ripple::less<Entry> >
private

Definition at line 89 of file Bootcache.h.

◆ map_type

using ripple::PeerFinder::Bootcache::map_type = boost::bimap<left_t, right_t>
private

Definition at line 90 of file Bootcache.h.

◆ value_type

using ripple::PeerFinder::Bootcache::value_type = map_type::value_type
private

Definition at line 91 of file Bootcache.h.

◆ iterator

using ripple::PeerFinder::Bootcache::iterator = boost:: transform_iterator<Transform, map_type::right_map::const_iterator>

Definition at line 126 of file Bootcache.h.

◆ const_iterator

Definition at line 128 of file Bootcache.h.

Constructor & Destructor Documentation

◆ Bootcache()

ripple::PeerFinder::Bootcache::Bootcache ( Store store,
clock_type clock,
beast::Journal  journal 
)

Definition at line 28 of file Bootcache.cpp.

◆ ~Bootcache()

ripple::PeerFinder::Bootcache::~Bootcache ( )

Definition at line 37 of file Bootcache.cpp.

Member Function Documentation

◆ empty()

bool ripple::PeerFinder::Bootcache::empty ( ) const

Returns true if the cache is empty.

Definition at line 43 of file Bootcache.cpp.

◆ size()

Bootcache::map_type::size_type ripple::PeerFinder::Bootcache::size ( ) const

Returns the number of entries in the cache.

Definition at line 49 of file Bootcache.cpp.

◆ begin()

Bootcache::const_iterator ripple::PeerFinder::Bootcache::begin ( ) const

IP::Endpoint iterators that traverse in decreasing valence.

Definition at line 55 of file Bootcache.cpp.

◆ cbegin()

Bootcache::const_iterator ripple::PeerFinder::Bootcache::cbegin ( ) const

Definition at line 61 of file Bootcache.cpp.

◆ end()

Bootcache::const_iterator ripple::PeerFinder::Bootcache::end ( ) const

Definition at line 67 of file Bootcache.cpp.

◆ cend()

Bootcache::const_iterator ripple::PeerFinder::Bootcache::cend ( ) const

Definition at line 73 of file Bootcache.cpp.

◆ clear()

void ripple::PeerFinder::Bootcache::clear ( )

Definition at line 79 of file Bootcache.cpp.

◆ load()

void ripple::PeerFinder::Bootcache::load ( )

Load the persisted data from the Store into the container.

Definition at line 88 of file Bootcache.cpp.

◆ insert()

bool ripple::PeerFinder::Bootcache::insert ( beast::IP::Endpoint const &  endpoint)

Add a newly-learned address to the cache.

Definition at line 111 of file Bootcache.cpp.

◆ insertStatic()

bool ripple::PeerFinder::Bootcache::insertStatic ( beast::IP::Endpoint const &  endpoint)

Add a staticallyconfigured address to the cache.

Definition at line 125 of file Bootcache.cpp.

◆ on_success()

void ripple::PeerFinder::Bootcache::on_success ( beast::IP::Endpoint const &  endpoint)

Called when an outbound connection handshake completes.

Definition at line 147 of file Bootcache.cpp.

◆ on_failure()

void ripple::PeerFinder::Bootcache::on_failure ( beast::IP::Endpoint const &  endpoint)

Called when an outbound connection attempt fails to handshake.

Definition at line 173 of file Bootcache.cpp.

◆ periodicActivity()

void ripple::PeerFinder::Bootcache::periodicActivity ( )

Stores the cache in the persistent database on a timer.

Definition at line 199 of file Bootcache.cpp.

◆ onWrite()

void ripple::PeerFinder::Bootcache::onWrite ( beast::PropertyStream::Map map)

Write the cache state to the property stream.

Definition at line 207 of file Bootcache.cpp.

◆ prune()

void ripple::PeerFinder::Bootcache::prune ( )
private

Definition at line 220 of file Bootcache.cpp.

◆ update()

void ripple::PeerFinder::Bootcache::update ( )
private

Definition at line 251 of file Bootcache.cpp.

◆ checkUpdate()

void ripple::PeerFinder::Bootcache::checkUpdate ( )
private

Definition at line 272 of file Bootcache.cpp.

◆ flagForUpdate()

void ripple::PeerFinder::Bootcache::flagForUpdate ( )
private

Definition at line 280 of file Bootcache.cpp.

Member Data Documentation

◆ m_map

map_type ripple::PeerFinder::Bootcache::m_map
private

Definition at line 110 of file Bootcache.h.

◆ m_store

Store& ripple::PeerFinder::Bootcache::m_store
private

Definition at line 112 of file Bootcache.h.

◆ m_clock

clock_type& ripple::PeerFinder::Bootcache::m_clock
private

Definition at line 113 of file Bootcache.h.

◆ m_journal

beast::Journal ripple::PeerFinder::Bootcache::m_journal
private

Definition at line 114 of file Bootcache.h.

◆ m_whenUpdate

clock_type::time_point ripple::PeerFinder::Bootcache::m_whenUpdate
private

Definition at line 117 of file Bootcache.h.

◆ m_needsUpdate

bool ripple::PeerFinder::Bootcache::m_needsUpdate
private

Definition at line 120 of file Bootcache.h.

◆ staticValence

constexpr int ripple::PeerFinder::Bootcache::staticValence = 32
staticconstexpr

Definition at line 123 of file Bootcache.h.