3#include <xrpl/basics/UnorderedContainers.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/beast/utility/instrumentation.h>
6#include <xrpl/consensus/ConsensusProposal.h>
7#include <xrpl/consensus/DisputedTx.h>
77 return "switchedLedger";
214 for (
auto const& [_, w] : times.
peers)
221 bool selfPlaced =
false;
226 XRPL_ASSERT(tally < halfWeight,
"xrpl::medianCloseOffset::step : median not yet found");
228 if (tally >= halfWeight)
236 for (
auto const& [t, w] : times.
peers)
238 if (!selfPlaced && times.
self <= t)
241 if (step(times.
self, 1))
247 if (!selfPlaced && !median)
253 UNREACHABLE(
"xrpl::medianCloseOffset : median not found");
282template <
class Traits>
295 XRPL_ASSERT(
txns.id() ==
position.position(),
"xrpl::ConsensusResult : valid inputs");
Represents a proposed position taken during a round of consensus.
Measures the duration of phases of consensus.
std::chrono::milliseconds dur_
void reset(time_point tp)
void tick(std::chrono::milliseconds fixed)
std::chrono::steady_clock::time_point time_point
std::chrono::milliseconds read() const
A transaction discovered to be in dispute during consensus.
std::chrono::time_point< NetClock > time_point
T duration_cast(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
ConsensusMode
Represents how a node currently participates in Consensus.
@ WrongLedger
We have the wrong ledger and are attempting to acquire it.
@ SwitchedLedger
We switched ledgers since we started this consensus round but are now running on what we believe is t...
@ Proposing
We are normal participant in consensus and propose our position.
@ Observing
We are observing peer positions, but not proposing our position.
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
static FunctionType fixed(Keylet const &keylet)
std::string to_string(BaseUInt< Bits, Tag > const &a)
ConsensusState
Whether we have or don't have a consensus.
@ Expired
Consensus time limit has hard-expired.
@ MovedOn
The network has consensus without us.
@ Yes
We have consensus along with the network.
@ No
We do not have consensus.
std::chrono::seconds medianCloseOffset(ConsensusCloseTimes const ×)
Offset of the network's close time relative to ours, using a weighted median.
ConsensusPhase
Phases of consensus for a single ledger round.
@ Accepted
We have accepted a new last closed ledger and are waiting on a call to startRound to begin the next c...
@ Establish
Establishing consensus by exchanging proposals with our peers.
@ Open
We haven't closed our ledger yet, but others might have.
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
Stores the set of initial close times.
NetClock::time_point self
Our close time estimate.
ConsensusCloseTimes()=default
std::map< NetClock::time_point, int > peers
Close time estimates, keep ordered for predictable traverse.
Adaptor::NodeID_t NodeID_t
ConsensusResult(TxSet_t &&s, Proposal_t &&p)
hash_map< typename Tx_t::ID, Dispute_t > disputes
ConsensusProposal< NodeID_t, typename Ledger_t::ID, typename TxSet_t::ID > Proposal_t
DisputedTx< Tx_t, NodeID_t > Dispute_t
hash_set< typename TxSet_t::ID > compares
Adaptor::Ledger_t Ledger_t
T time_since_epoch(T... args)