20 #include <test/csf/ledgers.h>
42 if (ancestor.
seq() <
seq())
68 Seq count = end - start;
69 while (count > Seq{0})
71 Seq step = count / Seq{2};
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];
Json::Value getJson() const
InstanceMap::value_type InstanceEntry
boost::container::flat_set< Tx > TxSetType
Ledger::ID nextID() const
Ledger::Seq mismatch(Ledger const &a, Ledger const &b)
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::vector< Ledger::ID > ancestors
IDs of this ledgers ancestors.
A ledger is a set of observed transactions and a sequence number identifying the ledger.
std::optional< Ledger > lookup(Ledger::ID const &id) const
Find the ledger with the given ID.
@ objectValue
object value (collection of name/value pairs).
ID operator[](Seq seq) const
Return the id of the ancestor with the given seq (if exists/known)
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
std::size_t branches(std::set< Ledger > const &ledgers) const
Determine the number of distinct branches for the set of ledgers.
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_
A type-safe wrap around standard integral types.
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.