1#include <test/csf/ledgers.h>
3#include <test/csf/Tx.h>
5#include <xrpl/basics/chrono.h>
6#include <xrpl/json/json_value.h>
7#include <xrpl/ledger/LedgerTiming.h>
32 if (ancestor.
seq() <
seq())
58 Seq count = end - start;
59 while (count >
Seq{0})
61 Seq const step = count /
Seq{2};
62 Seq curr = start + step;
63 if (a[curr] == b[curr])
67 count -= step +
Seq{1};
95 using namespace std::chrono_literals;
97 next.txs.insert(txs.begin(), txs.end());
99 next.closeTimeResolution = closeTimeResolution;
101 if (next.closeTimeAgree)
107 next.closeTime = parent.
closeTime() + 1s;
110 next.parentCloseTime = parent.
closeTime();
111 next.parentID = parent.
id();
112 next.ancestors.push_back(parent.
id());
117 using Entry = InstanceMap::left_value_type;
120 return Ledger(it->second, &(it->first));
129 return Ledger(it->first, &(it->second));
142 for (
Ledger const& ledger : ledgers)
149 for (
auto idx = 0; idx < tips.
size() && !found; ++idx)
151 bool const idxEarlier = tips[idx].seq() < ledger.seq();
152 Ledger const& earlier = idxEarlier ? tips[idx] : ledger;
153 Ledger const& later = idxEarlier ? ledger : tips[idx];
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
Ledger::ID nextID() const
InstanceMap::value_type InstanceEntry
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.
static std::size_t branches(std::set< Ledger > const &ledgers)
Determine the number of distinct branches for the set of ledgers.
A ledger is a set of observed transactions and a sequence number identifying the ledger.
Instance const * instance_
TaggedInteger< std::uint32_t, IdTag > ID
TaggedInteger< std::uint32_t, SeqTag > Seq
bool isAncestor(Ledger const &ancestor) const
Determine whether ancestor is really an ancestor of this ledger.
static Instance const kGenesis
ID operator[](Seq seq) const
Return the id of the ancestor with the given seq (if exists/known).
Ledger(ID id, Instance const *i)
NetClock::time_point closeTime() const
json::Value getJson() const
@ Object
object value (collection of name/value pairs).
boost::container::flat_set< Tx > TxSetType
Ledger::Seq mismatch(Ledger const &a, Ledger const &b)
std::chrono::time_point< Clock, Duration > effCloseTime(std::chrono::time_point< Clock, Duration > closeTime, std::chrono::duration< Rep, Period > resolution, std::chrono::time_point< Clock, Duration > priorCloseTime)
Calculate the effective ledger close time.