rippled
Loading...
Searching...
No Matches
Public Member Functions | List of all members
xrpl::PeerSet Class Referenceabstract

Supports data retrieval by managing a set of peers. More...

#include <PeerSet.h>

Inheritance diagram for xrpl::PeerSet:
Inheritance graph
[legend]

Public Member Functions

virtual ~PeerSet ()=default
 
virtual void addPeers (std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> hasItem, std::function< void(std::shared_ptr< Peer > const &)> onPeerAdded)=0
 Try add more peers.
 
template<typename MessageType >
void sendRequest (MessageType const &message, std::shared_ptr< Peer > const &peer)
 send a message
 
virtual void sendRequest (::google::protobuf::Message const &message, protocol::MessageType type, std::shared_ptr< Peer > const &peer)=0
 
virtual std::set< Peer::id_t > const & getPeerIds () const =0
 get the set of ids of previously added peers
 

Detailed Description

Supports data retrieval by managing a set of peers.

When desired data (such as a ledger or a transaction set) is missing locally it can be obtained by querying connected peers. This class manages common aspects of the retrieval. Callers maintain the set by adding and removing peers depending on whether the peers have useful information.

The data is represented by its hash.

Definition at line 20 of file PeerSet.h.

Constructor & Destructor Documentation

◆ ~PeerSet()

virtual xrpl::PeerSet::~PeerSet ( )
virtualdefault

Member Function Documentation

◆ addPeers()

virtual void xrpl::PeerSet::addPeers ( std::size_t  limit,
std::function< bool(std::shared_ptr< Peer > const &)>  hasItem,
std::function< void(std::shared_ptr< Peer > const &)>  onPeerAdded 
)
pure virtual

Try add more peers.

Parameters
limitnumber of peers to add
hasItemcallback that helps to select peers
onPeerAddedcallback called when a peer is added

Implemented in xrpl::test::TestPeerSet, xrpl::PeerSetImpl, and xrpl::DummyPeerSet.

◆ sendRequest() [1/2]

template<typename MessageType >
void xrpl::PeerSet::sendRequest ( MessageType const &  message,
std::shared_ptr< Peer > const &  peer 
)

send a message

Definition at line 40 of file PeerSet.h.

◆ sendRequest() [2/2]

virtual void xrpl::PeerSet::sendRequest ( ::google::protobuf::Message const &  message,
protocol::MessageType  type,
std::shared_ptr< Peer > const &  peer 
)
pure virtual

◆ getPeerIds()

virtual std::set< Peer::id_t > const & xrpl::PeerSet::getPeerIds ( ) const
pure virtual

get the set of ids of previously added peers

Implemented in xrpl::test::TestPeerSet, xrpl::PeerSetImpl, and xrpl::DummyPeerSet.