1#include <test/csf/ledgers.h>
23 if (ancestor.
seq() <
seq())
49 Seq count = end - start;
50 while (count >
Seq{0})
53 Seq curr = start + step;
54 if (a[curr] == b[curr])
58 count -= step +
Seq{1};
84 using namespace std::chrono_literals;
86 next.txs.insert(txs.begin(), txs.end());
88 next.closeTimeResolution = closeTimeResolution;
90 if (next.closeTimeAgree)
92 consensusCloseTime, closeTimeResolution, parent.
closeTime());
96 next.parentCloseTime = parent.
closeTime();
97 next.parentID = parent.
id();
98 next.ancestors.push_back(parent.
id());
103 using Entry = InstanceMap::left_value_type;
106 return Ledger(it->second, &(it->first));
115 return Ledger(it->first, &(it->second));
128 for (
Ledger const& ledger : ledgers)
135 for (
auto idx = 0; idx < tips.
size() && !found; ++idx)
137 bool const idxEarlier = tips[idx].seq() < ledger.seq();
138 Ledger const& earlier = idxEarlier ? tips[idx] : ledger;
139 Ledger const& later = idxEarlier ? ledger : tips[idx];
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.
A ledger is a set of observed transactions and a sequence number identifying the ledger.
static Instance const genesis
NetClock::time_point closeTime() const
Instance const * instance_
Json::Value getJson() 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)
tagged_integer< std::uint32_t, SeqTag > Seq
@ objectValue
object value (collection of name/value pairs).
boost::container::flat_set< Tx > TxSetType
Ledger::Seq mismatch(Ledger const &a, Ledger const &b)
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.