xrpld
Loading...
Searching...
No Matches
xrpl::PeerFinder::Livecache< Allocator > Class Template Reference

The Livecache holds the short-lived relayed Endpoint messages. More...

#include <Livecache.h>

Inheritance diagram for xrpl::PeerFinder::Livecache< Allocator >:
Collaboration diagram for xrpl::PeerFinder::Livecache< Allocator >:

Classes

class  HopsT

Public Types

using allocator_type = Allocator

Public Member Functions

 Livecache (clock_type &clock, beast::Journal journal, Allocator alloc=Allocator())
 Create the cache.
bool empty () const
 Returns true if the cache is empty.
cache_type::size_type size () const
 Returns the number of entries in the cache.
void expire ()
 Erase entries whose time has expired.
void insert (Endpoint const &ep)
 Creates or updates an existing Element based on a new message.
void onWrite (beast::PropertyStream::Map &map)
 Output statistics.

Public Attributes

class xrpl::PeerFinder::Livecache::HopsT hops

Protected Types

using list_type

Static Protected Member Functions

template<bool IsConst>
static Hop< IsConst > makeHop (beast::MaybeConst< IsConst, list_type >::type &list)

Private Types

using cache_type

Private Attributes

beast::Journal journal_
cache_type cache_

Detailed Description

template<class Allocator = std::allocator<char>>
class xrpl::PeerFinder::Livecache< Allocator >

The Livecache holds the short-lived relayed Endpoint messages.

Since peers only advertise themselves when they have open slots, we want these messages to expire rather quickly after the peer becomes full.

Addresses added to the cache are not connection-tested to see if they are connectable (with one small exception regarding neighbors). Therefore, these addresses are not suitable for persisting across launches or for bootstrapping, because they do not have verifiable and locally observed uptime and connectability information.

Definition at line 171 of file Livecache.h.

Member Typedef Documentation

◆ cache_type

template<class Allocator = std::allocator<char>>
using xrpl::PeerFinder::Livecache< Allocator >::cache_type
private
Initial value:
Allocator>
A version-independent IP address and port combination.
Definition IPEndpoint.h:17
detail::AgedOrderedContainer< false, true, Key, T, Clock, Compare, Allocator > aged_map
Definition aged_map.h:17

Definition at line 174 of file Livecache.h.

◆ allocator_type

template<class Allocator = std::allocator<char>>
using xrpl::PeerFinder::Livecache< Allocator >::allocator_type = Allocator

Definition at line 185 of file Livecache.h.

◆ list_type

Initial value:
boost::intrusive::make_list<Element, boost::intrusive::constant_time_size<false>>::type

Definition at line 40 of file Livecache.h.

Constructor & Destructor Documentation

◆ Livecache()

template<class Allocator>
xrpl::PeerFinder::Livecache< Allocator >::Livecache ( clock_type & clock,
beast::Journal journal,
Allocator alloc = Allocator() )

Create the cache.

Definition at line 362 of file Livecache.h.

Member Function Documentation

◆ empty()

template<class Allocator = std::allocator<char>>
bool xrpl::PeerFinder::Livecache< Allocator >::empty ( ) const
nodiscard

Returns true if the cache is empty.

Definition at line 334 of file Livecache.h.

◆ size()

template<class Allocator = std::allocator<char>>
cache_type::size_type xrpl::PeerFinder::Livecache< Allocator >::size ( ) const

Returns the number of entries in the cache.

Definition at line 341 of file Livecache.h.

◆ expire()

template<class Allocator>
void xrpl::PeerFinder::Livecache< Allocator >::expire ( )

Erase entries whose time has expired.

Definition at line 369 of file Livecache.h.

◆ insert()

template<class Allocator>
void xrpl::PeerFinder::Livecache< Allocator >::insert ( Endpoint const & ep)

Creates or updates an existing Element based on a new message.

Definition at line 391 of file Livecache.h.

◆ onWrite()

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

Output statistics.

Definition at line 438 of file Livecache.h.

◆ makeHop()

template<bool IsConst>
Hop< IsConst > xrpl::PeerFinder::detail::LivecacheBase::makeHop ( beast::MaybeConst< IsConst, list_type >::type & list)
staticprotectedinherited

Definition at line 148 of file Livecache.h.

Member Data Documentation

◆ journal_

template<class Allocator = std::allocator<char>>
beast::Journal xrpl::PeerFinder::Livecache< Allocator >::journal_
private

Definition at line 181 of file Livecache.h.

◆ cache_

template<class Allocator = std::allocator<char>>
cache_type xrpl::PeerFinder::Livecache< Allocator >::cache_
private

Definition at line 182 of file Livecache.h.

◆ hops

template<class Allocator = std::allocator<char>>
class xrpl::PeerFinder::Livecache::HopsT xrpl::PeerFinder::Livecache< Allocator >::hops