rippled
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ripple::test::csf::Ledger Class Reference

A ledger is a set of observed transactions and a sequence number identifying the ledger. More...

#include <ledgers.h>

Collaboration diagram for ripple::test::csf::Ledger:
Collaboration graph
[legend]

Classes

struct  Instance
 
struct  MakeGenesis
 

Public Types

using Seq = tagged_integer< std::uint32_t, SeqTag >
 
using ID = tagged_integer< std::uint32_t, IdTag >
 

Public Member Functions

 Ledger (MakeGenesis)
 
 Ledger ()
 
ID id () const
 
Seq seq () const
 
NetClock::duration closeTimeResolution () const
 
bool closeAgree () const
 
NetClock::time_point closeTime () const
 
NetClock::time_point parentCloseTime () const
 
ID parentID () const
 
TxSetType const & txs () const
 
bool isAncestor (Ledger const &ancestor) const
 Determine whether ancestor is really an ancestor of this ledger.
 
ID operator[] (Seq seq) const
 Return the id of the ancestor with the given seq (if exists/known)
 
Json::Value getJson () const
 

Private Member Functions

 Ledger (ID id, Instance const *i)
 

Private Attributes

ID id_ {0}
 
Instance const * instance_
 

Static Private Attributes

static Instance const genesis
 

Friends

class LedgerOracle
 
Ledger::Seq mismatch (Ledger const &a, Ledger const &o)
 Return the sequence number of the first mismatching ancestor.
 
bool operator< (Ledger const &a, Ledger const &b)
 

Detailed Description

A ledger is a set of observed transactions and a sequence number identifying the ledger.

Peers in the consensus process are trying to agree on a set of transactions to include in a ledger. For simulation, each transaction is a single integer and the ledger is the set of observed integers. This means future ledgers have prior ledgers as subsets, e.g.

Ledger 0 :  {}
Ledger 1 :  {1,4,5}
Ledger 2 :  {1,2,4,5,10}
....

Ledgers are immutable value types. All ledgers with the same sequence number, transactions, close time, etc. will have the same ledger ID. The LedgerOracle class below manges ID assignments for a simulation and is the only way to close and create a new ledger. Since the parent ledger ID is part of type, this also means ledgers with distinct histories will have distinct ids, even if they have the same set of transactions, sequence number and close time.

Definition at line 44 of file ledgers.h.

Member Typedef Documentation

◆ Seq

Definition at line 50 of file ledgers.h.

◆ ID

Definition at line 53 of file ledgers.h.

Constructor & Destructor Documentation

◆ Ledger() [1/3]

ripple::test::csf::Ledger::Ledger ( ID  id,
Instance const *  i 
)
private

Definition at line 137 of file ledgers.h.

◆ Ledger() [2/3]

ripple::test::csf::Ledger::Ledger ( MakeGenesis  )

Definition at line 142 of file ledgers.h.

◆ Ledger() [3/3]

ripple::test::csf::Ledger::Ledger ( )

Definition at line 148 of file ledgers.h.

Member Function Documentation

◆ id()

ID ripple::test::csf::Ledger::id ( ) const

Definition at line 153 of file ledgers.h.

◆ seq()

Seq ripple::test::csf::Ledger::seq ( ) const

Definition at line 159 of file ledgers.h.

◆ closeTimeResolution()

NetClock::duration ripple::test::csf::Ledger::closeTimeResolution ( ) const

Definition at line 165 of file ledgers.h.

◆ closeAgree()

bool ripple::test::csf::Ledger::closeAgree ( ) const

Definition at line 171 of file ledgers.h.

◆ closeTime()

NetClock::time_point ripple::test::csf::Ledger::closeTime ( ) const

Definition at line 177 of file ledgers.h.

◆ parentCloseTime()

NetClock::time_point ripple::test::csf::Ledger::parentCloseTime ( ) const

Definition at line 183 of file ledgers.h.

◆ parentID()

ID ripple::test::csf::Ledger::parentID ( ) const

Definition at line 189 of file ledgers.h.

◆ txs()

TxSetType const & ripple::test::csf::Ledger::txs ( ) const

Definition at line 195 of file ledgers.h.

◆ isAncestor()

bool ripple::test::csf::Ledger::isAncestor ( Ledger const &  ancestor) const

Determine whether ancestor is really an ancestor of this ledger.

Definition at line 21 of file ledgers.cpp.

◆ operator[]()

Ledger::ID ripple::test::csf::Ledger::operator[] ( Seq  seq) const

Return the id of the ancestor with the given seq (if exists/known)

Definition at line 29 of file ledgers.cpp.

◆ getJson()

Json::Value ripple::test::csf::Ledger::getJson ( ) const

Definition at line 12 of file ledgers.cpp.

Friends And Related Symbol Documentation

◆ LedgerOracle

friend class LedgerOracle
friend

Definition at line 46 of file ledgers.h.

◆ mismatch

Ledger::Seq mismatch ( Ledger const &  a,
Ledger const &  o 
)
friend

Return the sequence number of the first mismatching ancestor.

Definition at line 39 of file ledgers.cpp.

◆ operator<

bool operator< ( Ledger const &  a,
Ledger const &  b 
)
friend

Definition at line 217 of file ledgers.h.

Member Data Documentation

◆ genesis

Ledger::Instance const ripple::test::csf::Ledger::genesis
staticprivate

Definition at line 135 of file ledgers.h.

◆ id_

ID ripple::test::csf::Ledger::id_ {0}
private

Definition at line 224 of file ledgers.h.

◆ instance_

Instance const* ripple::test::csf::Ledger::instance_
private

Definition at line 225 of file ledgers.h.