19 #ifndef RIPPLE_TEST_CSF_LEDGERS_H_INCLUDED
20 #define RIPPLE_TEST_CSF_LEDGERS_H_INCLUDED
22 #include <ripple/basics/UnorderedContainers.h>
23 #include <ripple/basics/chrono.h>
24 #include <ripple/basics/comparators.h>
25 #include <ripple/basics/tagged_integer.h>
26 #include <ripple/consensus/LedgerTiming.h>
27 #include <ripple/json/json_value.h>
28 #include <boost/bimap/bimap.hpp>
31 #include <test/csf/Tx.h>
139 template <
class Hasher>
234 return a.
id() < b.
id();
247 boost::bimaps::set_of<Ledger::Instance, ripple::less<Ledger::Instance>>,
248 boost::bimaps::set_of<Ledger::ID, ripple::less<Ledger::ID>>>;
283 using namespace std::chrono_literals;
343 auto it = ledgers.
find(s);
344 if (it != ledgers.
end())
Json::Value getJson() const
InstanceMap::value_type InstanceEntry
friend bool operator!=(Instance const &a, Instance const &b)
boost::container::flat_set< Tx > TxSetType
Ledger::ID nextID() const
Ledger accept(Ledger const &curr, Tx tx)
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::unordered_map< std::string, Ledger > ledgers
bool closeTimeAgree
Whether consensus agreed on the close time.
TxSetType const & txs() const
std::vector< Ledger::ID > ancestors
IDs of this ledgers ancestors.
A ledger is a set of observed transactions and a sequence number identifying the ledger.
NetClock::time_point parentCloseTime
Parent ledger close time.
NetClock::duration closeTimeResolution() const
Helper for writing unit tests with controlled ledger histories.
std::optional< Ledger > lookup(Ledger::ID const &id) const
Find the ledger with the given ID.
friend bool operator<(Instance const &a, Instance const &b)
NetClock::time_point parentCloseTime() const
Oracle maintaining unique ledgers for a simulation.
ID operator[](Seq seq) const
Return the id of the ancestor with the given seq (if exists/known)
NetClock::time_point closeTime
When the ledger closed (up to closeTimeResolution)
Ledger(ID id, Instance const *i)
ID parentID
Parent ledger id.
friend bool operator==(Instance const &a, Instance const &b)
friend Ledger::Seq mismatch(Ledger const &a, Ledger const &o)
Return the sequence number of the first mismatching ancestor.
NetClock::time_point closeTime() const
Set the sequence number on a JTx.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static const Instance genesis
friend void hash_append(Hasher &h, Ledger::Instance const &instance)
std::size_t branches(std::set< Ledger > const &ledgers) const
Determine the number of distinct branches for the set of ledgers.
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.
tagged_integer< std::uint32_t, IdTag > ID
bool isAncestor(Ledger const &ancestor) const
Determine whether ancestor is really an ancestor of this ledger.
tagged_integer< std::uint32_t, SeqTag > Seq
Instance const * instance_
NetClock::duration closeTimeResolution
constexpr auto ledgerDefaultTimeResolution
Initial resolution of ledger close time.
friend bool operator<(Ledger const &a, Ledger const &b)
Ledger const & operator[](std::string const &s)
Get or create the ledger with the given string history.
boost::bimaps::bimap< boost::bimaps::set_of< Ledger::Instance, ripple::less< Ledger::Instance > >, boost::bimaps::set_of< Ledger::ID, ripple::less< Ledger::ID > >> InstanceMap