xrpld
Loading...
Searching...
No Matches
xrpl::test::TestPeerSet Struct Referenceabstract

Simulate a peerSet that supplies peers to ledger replay subtasks. More...

Inheritance diagram for xrpl::test::TestPeerSet:
Collaboration diagram for xrpl::test::TestPeerSet:

Public Member Functions

 TestPeerSet (LedgerReplayMsgHandler &me, LedgerReplayMsgHandler &other, PeerSetBehavior bhvr, bool enableLedgerReplay)
void addPeers (std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> hasItem, std::function< void(std::shared_ptr< Peer > const &)> onPeerAdded) override
void sendRequest (::google::protobuf::Message const &msg, protocol::MessageType type, std::shared_ptr< Peer > const &peer) override
std::set< Peer::ID > const & getPeerIds () const override
 get the set of ids of previously added peers
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

Public Attributes

LedgerReplayMsgHandler & local
LedgerReplayMsgHandler & remote
std::shared_ptr< TestPeer > dummyPeer
PeerSetBehavior behavior
std::atomic< int > sendCount {0}

Detailed Description

Simulate a peerSet that supplies peers to ledger replay subtasks.

It connects the ledger replay client side and server side message handlers. Depending on the configured PeerSetBehavior, it may drop or repeat some of the messages.

Definition at line 310 of file LedgerReplay_test.cpp.

Constructor & Destructor Documentation

◆ TestPeerSet()

xrpl::test::TestPeerSet::TestPeerSet ( LedgerReplayMsgHandler & me,
LedgerReplayMsgHandler & other,
PeerSetBehavior bhvr,
bool enableLedgerReplay )

Definition at line 312 of file LedgerReplay_test.cpp.

Member Function Documentation

◆ addPeers() [1/2]

void xrpl::test::TestPeerSet::addPeers ( std::size_t limit,
std::function< bool(std::shared_ptr< Peer > const &)> hasItem,
std::function< void(std::shared_ptr< Peer > const &)> onPeerAdded )
override

Definition at line 325 of file LedgerReplay_test.cpp.

◆ sendRequest() [1/3]

void xrpl::test::TestPeerSet::sendRequest ( ::google::protobuf::Message const & msg,
protocol::MessageType type,
std::shared_ptr< Peer > const & peer )
override

Definition at line 335 of file LedgerReplay_test.cpp.

◆ getPeerIds()

std::set< Peer::ID > const & xrpl::test::TestPeerSet::getPeerIds ( ) const
nodiscardoverridevirtual

get the set of ids of previously added peers

Implements xrpl::PeerSet.

Definition at line 381 of file LedgerReplay_test.cpp.

◆ addPeers() [2/2]

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 virtualinherited

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::DummyPeerSet, and xrpl::PeerSetImpl.

◆ sendRequest() [2/3]

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

send a message

Definition at line 51 of file PeerSet.h.

◆ sendRequest() [3/3]

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

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

Member Data Documentation

◆ local

LedgerReplayMsgHandler& xrpl::test::TestPeerSet::local

Definition at line 387 of file LedgerReplay_test.cpp.

◆ remote

LedgerReplayMsgHandler& xrpl::test::TestPeerSet::remote

Definition at line 388 of file LedgerReplay_test.cpp.

◆ dummyPeer

std::shared_ptr<TestPeer> xrpl::test::TestPeerSet::dummyPeer

Definition at line 389 of file LedgerReplay_test.cpp.

◆ behavior

PeerSetBehavior xrpl::test::TestPeerSet::behavior

Definition at line 390 of file LedgerReplay_test.cpp.

◆ sendCount

std::atomic<int> xrpl::test::TestPeerSet::sendCount {0}

Definition at line 391 of file LedgerReplay_test.cpp.