19 #include <test/csf/ledgers.h>
42 if (ancestor.
seq() <
seq())
69 Seq count = end - start;
72 Seq step = count/Seq{2};
73 Seq curr = start + step;
74 if(a[curr] == b[curr])
78 count -= step + Seq{1};
104 using namespace std::chrono_literals;
106 next.txs.insert(txs.begin(), txs.end());
108 next.closeTimeResolution = closeTimeResolution;
110 if(next.closeTimeAgree)
112 consensusCloseTime, closeTimeResolution, parent.
closeTime());
114 next.closeTime = parent.
closeTime() + 1s;
116 next.parentCloseTime = parent.
closeTime();
117 next.parentID = parent.
id();
118 next.ancestors.push_back(parent.
id());
123 using Entry = InstanceMap::left_value_type;
126 return Ledger(it->second, &(it->first));
129 boost::optional<Ledger>
135 return Ledger(it->first, &(it->second));
149 for (
Ledger const & ledger : ledgers)
156 for (
auto idx = 0; idx < tips.
size() && !found; ++idx)
158 bool const idxEarlier = tips[idx].seq() < ledger.seq();
159 Ledger const & earlier = idxEarlier ? tips[idx] : ledger;
160 Ledger const & later = idxEarlier ? ledger : tips[idx] ;
Json::Value getJson() const
InstanceMap::value_type InstanceEntry
boost::optional< Ledger > lookup(Ledger::ID const &id) const
Find the ledger with the given ID.
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.
@ 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_
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.