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

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

#include <PeerSet.h>

Inheritance diagram for ripple::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 39 of file PeerSet.h.

Constructor & Destructor Documentation

◆ ~PeerSet()

virtual ripple::PeerSet::~PeerSet ( )
virtualdefault

Member Function Documentation

◆ addPeers()

virtual void ripple::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 ripple::test::TestPeerSet, ripple::PeerSetImpl, and ripple::DummyPeerSet.

◆ sendRequest() [1/2]

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

send a message

Definition at line 59 of file PeerSet.h.

◆ sendRequest() [2/2]

virtual void ripple::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 & ripple::PeerSet::getPeerIds ( ) const
pure virtual

get the set of ids of previously added peers

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