1#ifndef XRPL_TEST_CSF_LEDGERS_H_INCLUDED
2#define XRPL_TEST_CSF_LEDGERS_H_INCLUDED
4#include <test/csf/Tx.h>
6#include <xrpld/consensus/LedgerTiming.h>
8#include <xrpl/basics/UnorderedContainers.h>
9#include <xrpl/basics/chrono.h>
10#include <xrpl/basics/comparators.h>
11#include <xrpl/basics/tagged_integer.h>
12#include <xrpl/json/json_value.h>
14#include <boost/bimap/bimap.hpp>
125 template <
class Hasher>
220 return a.
id() < b.
id();
233 boost::bimaps::set_of<Ledger::Instance, ripple::less<Ledger::Instance>>,
234 boost::bimaps::set_of<Ledger::ID, ripple::less<Ledger::ID>>>;
269 using namespace std::chrono_literals;
Oracle maintaining unique ledgers for a simulation.
Ledger accept(Ledger const &curr, Tx tx)
InstanceMap::value_type InstanceEntry
Ledger::ID nextID() const
Ledger accept(Ledger const &curr, TxSetType const &txs, NetClock::duration closeTimeResolution, NetClock::time_point const &consensusCloseTime)
Accept the given txs and generate a new ledger.
std::optional< Ledger > lookup(Ledger::ID const &id) const
Find the ledger with the given ID.
std::size_t branches(std::set< Ledger > const &ledgers) const
Determine the number of distinct branches for the set of ledgers.
boost::bimaps::bimap< boost::bimaps::set_of< Ledger::Instance, ripple::less< Ledger::Instance > >, boost::bimaps::set_of< Ledger::ID, ripple::less< Ledger::ID > > > InstanceMap
A ledger is a set of observed transactions and a sequence number identifying the ledger.
static Instance const genesis
friend bool operator<(Ledger const &a, Ledger const &b)
NetClock::duration closeTimeResolution() const
NetClock::time_point parentCloseTime() const
friend Ledger::Seq mismatch(Ledger const &a, Ledger const &o)
Return the sequence number of the first mismatching ancestor.
NetClock::time_point closeTime() const
Instance const * instance_
Json::Value getJson() 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)
Ledger(ID id, Instance const *i)
tagged_integer< std::uint32_t, SeqTag > Seq
tagged_integer< std::uint32_t, IdTag > ID
std::enable_if_t< is_contiguously_hashable< T, Hasher >::value > hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
boost::container::flat_set< Tx > TxSetType
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
auto constexpr ledgerDefaultTimeResolution
Initial resolution of ledger close time.
Helper for writing unit tests with controlled ledger histories.
Ledger const & operator[](std::string const &s)
Get or create the ledger with the given string history.
std::unordered_map< std::string, Ledger > ledgers
NetClock::time_point parentCloseTime
Parent ledger close time.
friend bool operator==(Instance const &a, Instance const &b)
NetClock::duration closeTimeResolution
ID parentID
Parent ledger id.
bool closeTimeAgree
Whether consensus agreed on the close time.
friend bool operator<(Instance const &a, Instance const &b)
friend bool operator!=(Instance const &a, Instance const &b)
friend void hash_append(Hasher &h, Ledger::Instance const &instance)
std::vector< Ledger::ID > ancestors
IDs of this ledgers ancestors.
NetClock::time_point closeTime
When the ledger closed (up to closeTimeResolution)
Set the sequence number on a JTx.