rippled
Public Member Functions | Public Attributes | Private Attributes | List of all members
ripple::test::csf::Sim Class Reference
Collaboration diagram for ripple::test::csf::Sim:
Collaboration graph
[legend]

Public Member Functions

 Sim ()
 Create a simulation. More...
 
PeerGroup createGroup (std::size_t numPeers)
 Create a new group of peers. More...
 
std::size_t size () const
 The number of peers in the simulation. More...
 
void run (int ledgers)
 Run consensus protocol to generate the provided number of ledgers. More...
 
void run (SimDuration const &dur)
 Run consensus for the given duration. More...
 
bool synchronized (PeerGroup const &g) const
 Check whether all peers in the group are synchronized. More...
 
bool synchronized () const
 Check whether all peers in the network are synchronized. More...
 
std::size_t branches (PeerGroup const &g) const
 Calculate the number of branches in the group. More...
 
std::size_t branches () const
 Calculate the number of branches in the network. More...
 

Public Attributes

std::mt19937_64 rng
 
Scheduler scheduler
 
BasicSink sink
 
beast::Journal j
 
LedgerOracle oracle
 
BasicNetwork< Peer * > net
 
TrustGraph< Peer * > trustGraph
 
CollectorRefs collectors
 

Private Attributes

std::deque< Peerpeers
 
PeerGroup allPeers
 

Detailed Description

Definition at line 62 of file Sim.h.

Constructor & Destructor Documentation

◆ Sim()

ripple::test::csf::Sim::Sim ( )

Create a simulation.

Creates a new simulation. The simulation has no peers, no trust links and no network connections.

Definition at line 85 of file Sim.h.

Member Function Documentation

◆ createGroup()

PeerGroup ripple::test::csf::Sim::createGroup ( std::size_t  numPeers)

Create a new group of peers.

Creates a new group of peers. The peers do not have any trust relations or network connections by default. Those must be configured by the client.

Parameters
numPeersThe number of peers in the group
Returns
PeerGroup representing these new peers
Note
This increases the number of peers in the simulation by numPeers.

Definition at line 101 of file Sim.h.

◆ size()

std::size_t ripple::test::csf::Sim::size ( ) const

The number of peers in the simulation.

Definition at line 124 of file Sim.h.

◆ run() [1/2]

void ripple::test::csf::Sim::run ( int  ledgers)

Run consensus protocol to generate the provided number of ledgers.

Has each peer run consensus until it closes ledgers more ledgers.

Parameters
ledgersThe number of additional ledgers to close

Definition at line 26 of file Sim.cpp.

◆ run() [2/2]

void ripple::test::csf::Sim::run ( SimDuration const &  dur)

Run consensus for the given duration.

Definition at line 37 of file Sim.cpp.

◆ synchronized() [1/2]

bool ripple::test::csf::Sim::synchronized ( PeerGroup const &  g) const

Check whether all peers in the group are synchronized.

Nodes in the group are synchronized if they share the same last fully validated and last generated ledger.

Definition at line 54 of file Sim.cpp.

◆ synchronized() [2/2]

bool ripple::test::csf::Sim::synchronized ( ) const

Check whether all peers in the network are synchronized.

Definition at line 48 of file Sim.cpp.

◆ branches() [1/2]

std::size_t ripple::test::csf::Sim::branches ( PeerGroup const &  g) const

Calculate the number of branches in the group.

A branch occurs if two nodes in the group have fullyValidatedLedgers that are not on the same chain of ledgers.

Definition at line 71 of file Sim.cpp.

◆ branches() [2/2]

std::size_t ripple::test::csf::Sim::branches ( ) const

Calculate the number of branches in the network.

Definition at line 66 of file Sim.cpp.

Member Data Documentation

◆ peers

std::deque<Peer> ripple::test::csf::Sim::peers
private

Definition at line 66 of file Sim.h.

◆ allPeers

PeerGroup ripple::test::csf::Sim::allPeers
private

Definition at line 67 of file Sim.h.

◆ rng

std::mt19937_64 ripple::test::csf::Sim::rng

Definition at line 70 of file Sim.h.

◆ scheduler

Scheduler ripple::test::csf::Sim::scheduler

Definition at line 71 of file Sim.h.

◆ sink

BasicSink ripple::test::csf::Sim::sink

Definition at line 72 of file Sim.h.

◆ j

beast::Journal ripple::test::csf::Sim::j

Definition at line 73 of file Sim.h.

◆ oracle

LedgerOracle ripple::test::csf::Sim::oracle

Definition at line 74 of file Sim.h.

◆ net

BasicNetwork<Peer*> ripple::test::csf::Sim::net

Definition at line 75 of file Sim.h.

◆ trustGraph

TrustGraph<Peer*> ripple::test::csf::Sim::trustGraph

Definition at line 76 of file Sim.h.

◆ collectors

CollectorRefs ripple::test::csf::Sim::collectors

Definition at line 77 of file Sim.h.