1#include <test/csf/ledgers.h>
23 if (ancestor.
seq() <
seq())
49 Seq count = end - start;
50 while (count >
Seq{0})
52 Seq const step = count /
Seq{2};
53 Seq curr = start + step;
54 if (a[curr] == b[curr])
58 count -= step +
Seq{1};
86 using namespace std::chrono_literals;
88 next.txs.insert(txs.begin(), txs.end());
90 next.closeTimeResolution = closeTimeResolution;
92 if (next.closeTimeAgree)
101 next.parentCloseTime = parent.
closeTime();
102 next.parentID = parent.
id();
103 next.ancestors.push_back(parent.
id());
108 using Entry = InstanceMap::left_value_type;
111 return Ledger(it->second, &(it->first));
120 return Ledger(it->first, &(it->second));
133 for (
Ledger const& ledger : ledgers)
140 for (
auto idx = 0; idx < tips.
size() && !found; ++idx)
142 bool const idxEarlier = tips[idx].seq() < ledger.seq();
143 Ledger const& earlier = idxEarlier ? tips[idx] : ledger;
144 Ledger const& later = idxEarlier ? ledger : tips[idx];
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_
bool isAncestor(Ledger const &ancestor) const
Determine whether ancestor is really an ancestor of this ledger.
Json::Value getJson() const
static Instance const genesis
ID operator[](Seq seq) const
Return the id of the ancestor with the given seq (if exists/known)
NetClock::time_point closeTime() const
tagged_integer< std::uint32_t, SeqTag > Seq
@ objectValue
object value (collection of name/value pairs).
Ledger::Seq mismatch(Ledger const &a, Ledger const &b)
boost::container::flat_set< Tx > TxSetType
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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.
std::vector< Ledger::ID > ancestors
IDs of this ledgers ancestors.
Set the sequence number on a JTx.