rippled
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ripple::test::TestPeerSet Struct Reference

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

Inheritance diagram for ripple::test::TestPeerSet:
Inheritance graph
[legend]
Collaboration diagram for ripple::test::TestPeerSet:
Collaboration graph
[legend]

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
 Try add more peers.
 
void sendRequest (::google::protobuf::Message const &msg, protocol::MessageType type, std::shared_ptr< Peer > const &peer) override
 
std::set< Peer::id_t > const & getPeerIds () const override
 get the set of ids of previously added peers
 
template<typename MessageType >
void sendRequest (MessageType const &message, std::shared_ptr< Peer > const &peer)
 send a message
 

Public Attributes

LedgerReplayMsgHandlerlocal
 
LedgerReplayMsgHandlerremote
 
std::shared_ptr< TestPeerdummyPeer
 
PeerSetBehavior behavior
 

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 335 of file LedgerReplay_test.cpp.

Constructor & Destructor Documentation

◆ TestPeerSet()

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

Definition at line 337 of file LedgerReplay_test.cpp.

Member Function Documentation

◆ addPeers()

void ripple::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 
)
overridevirtual

Try add more peers.

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

Implements ripple::PeerSet.

Definition at line 350 of file LedgerReplay_test.cpp.

◆ sendRequest() [1/2]

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

Implements ripple::PeerSet.

Definition at line 360 of file LedgerReplay_test.cpp.

◆ getPeerIds()

std::set< Peer::id_t > const & ripple::test::TestPeerSet::getPeerIds ( ) const
overridevirtual

get the set of ids of previously added peers

Implements ripple::PeerSet.

Definition at line 406 of file LedgerReplay_test.cpp.

◆ sendRequest() [2/2]

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

send a message

Definition at line 40 of file PeerSet.h.

Member Data Documentation

◆ local

LedgerReplayMsgHandler& ripple::test::TestPeerSet::local

Definition at line 412 of file LedgerReplay_test.cpp.

◆ remote

LedgerReplayMsgHandler& ripple::test::TestPeerSet::remote

Definition at line 413 of file LedgerReplay_test.cpp.

◆ dummyPeer

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

Definition at line 414 of file LedgerReplay_test.cpp.

◆ behavior

PeerSetBehavior ripple::test::TestPeerSet::behavior

Definition at line 415 of file LedgerReplay_test.cpp.