xrpld
Loading...
Searching...
No Matches
xrpl::test::csf::Sim Class Reference

#include <Sim.h>

Collaboration diagram for xrpl::test::csf::Sim:

Public Member Functions

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

Static Public Member Functions

static bool synchronized (PeerGroup const &g)
 Check whether all peers in the group are synchronized.

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 45 of file Sim.h.

Constructor & Destructor Documentation

◆ Sim()

xrpl::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 69 of file Sim.h.

Member Function Documentation

◆ createGroup()

PeerGroup xrpl::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 85 of file Sim.h.

◆ size()

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

The number of peers in the simulation.

Definition at line 108 of file Sim.h.

◆ run() [1/2]

void xrpl::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 14 of file Sim.cpp.

◆ run() [2/2]

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

Run consensus for the given duration.

Definition at line 25 of file Sim.cpp.

◆ synchronized() [1/2]

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

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 42 of file Sim.cpp.

◆ synchronized() [2/2]

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

Check whether all peers in the network are synchronized.

Definition at line 36 of file Sim.cpp.

◆ branches() [1/2]

std::size_t xrpl::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 59 of file Sim.cpp.

◆ branches() [2/2]

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

Calculate the number of branches in the network.

Definition at line 54 of file Sim.cpp.

Member Data Documentation

◆ peers_

std::deque<Peer> xrpl::test::csf::Sim::peers_
private

Definition at line 49 of file Sim.h.

◆ allPeers_

PeerGroup xrpl::test::csf::Sim::allPeers_
private

Definition at line 50 of file Sim.h.

◆ rng

std::mt19937_64 xrpl::test::csf::Sim::rng

Definition at line 53 of file Sim.h.

◆ scheduler

Scheduler xrpl::test::csf::Sim::scheduler

Definition at line 54 of file Sim.h.

◆ sink

BasicSink xrpl::test::csf::Sim::sink

Definition at line 55 of file Sim.h.

◆ j

beast::Journal xrpl::test::csf::Sim::j

Definition at line 56 of file Sim.h.

◆ oracle

LedgerOracle xrpl::test::csf::Sim::oracle

Definition at line 57 of file Sim.h.

◆ net

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

Definition at line 58 of file Sim.h.

◆ trustGraph

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

Definition at line 59 of file Sim.h.

◆ collectors

CollectorRefs xrpl::test::csf::Sim::collectors

Definition at line 60 of file Sim.h.