xrpld
Loading...
Searching...
No Matches
ConsensusTypes.h
1#pragma once
2
3#include <xrpld/consensus/ConsensusProposal.h>
4#include <xrpld/consensus/DisputedTx.h>
5
6#include <xrpl/basics/chrono.h>
7
8#include <chrono>
9#include <map>
10
11namespace xrpl {
12
50
51inline std::string
53{
54 switch (m)
55 {
57 return "proposing";
59 return "observing";
61 return "wrongLedger";
63 return "switchedLedger";
64 default:
65 return "unknown";
66 }
67}
68
97
98inline std::string
100{
101 switch (p)
102 {
104 return "open";
106 return "establish";
108 return "accepted";
109 default:
110 return "unknown";
111 }
112}
113
117{
118 using time_point = std::chrono::steady_clock::time_point;
121
122public:
123 [[nodiscard]] std::chrono::milliseconds
124 read() const
125 {
126 return dur_;
127 }
128
129 void
134
135 void
137 {
138 start_ = tp;
140 }
141
142 void
144 {
145 using namespace std::chrono;
147 }
148};
149
166
174
183template <class Traits>
185{
186 using Ledger_t = Traits::Ledger_t;
187 using TxSet_t = Traits::TxSet_t;
188 using NodeID_t = Traits::NodeID_t;
189
190 using Tx_t = TxSet_t::Tx;
193
194 ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)}
195 {
196 XRPL_ASSERT(txns.id() == position.position(), "xrpl::ConsensusResult : valid inputs");
197 }
198
201
204
207
208 // Set of TxSet ids we have already compared/created disputes
210
211 // Measures the duration of the establish phase for this consensus round
213
214 // Indicates state in which consensus ended. Once in the accept phase
215 // will be either Yes or MovedOn or Expired
217
218 // The number of peers proposing during the round
220};
221} // namespace xrpl
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
void tick(time_point tp)
A transaction discovered to be in dispute during consensus.
Definition DisputedTx.h:31
std::chrono::time_point< NetClock > time_point
Definition chrono.h:46
T duration_cast(T... args)
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
ConsensusMode
Represents how a node currently participates in Consensus.
@ WrongLedger
We have the wrong ledger and are attempting to acquire it.
@ Proposing
We are normal participant in consensus and propose our position.
@ Observing
We are observing peer positions, but not proposing our position.
@ Expired
List is expired, but has the largest non-pending sequence seen so far.
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
static FunctionType fixed(Keylet const &keylet)
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:633
ConsensusState
Whether we have or don't have a consensus.
@ MovedOn
The network has consensus without us.
@ No
We do not have consensus.
ConsensusPhase
Phases of consensus for a single ledger round.
@ 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
@ Accepted
Manifest is valid.
Definition Manifest.h:197
NetClock::time_point self
Our close time estimate.
std::map< NetClock::time_point, int > peers
Close time estimates, keep ordered for predictable traverse.
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