20#include <test/csf/ledgers.h>
42 if (ancestor.
seq() <
seq())
68 Seq count = end - start;
69 while (count >
Seq{0})
72 Seq curr = start + step;
73 if (a[curr] == b[curr])
77 count -= step +
Seq{1};
103 using namespace std::chrono_literals;
105 next.txs.insert(txs.begin(), txs.end());
107 next.closeTimeResolution = closeTimeResolution;
109 if (next.closeTimeAgree)
111 consensusCloseTime, closeTimeResolution, parent.
closeTime());
113 next.closeTime = parent.
closeTime() + 1s;
115 next.parentCloseTime = parent.
closeTime();
116 next.parentID = parent.
id();
117 next.ancestors.push_back(parent.
id());
122 using Entry = InstanceMap::left_value_type;
125 return Ledger(it->second, &(it->first));
134 return Ledger(it->first, &(it->second));
147 for (
Ledger const& ledger : ledgers)
154 for (
auto idx = 0; idx < tips.
size() && !found; ++idx)
156 bool const idxEarlier = tips[idx].seq() < ledger.seq();
157 Ledger const& earlier = idxEarlier ? tips[idx] : ledger;
158 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.