20#include <xrpld/consensus/Consensus.h>
21#include <xrpl/basics/Log.h>
39 using namespace std::chrono_literals;
40 if ((prevRoundTime < -1s) || (prevRoundTime > 10min) ||
41 (timeSincePrevClose > 10min))
44 JLOG(j.
warn()) <<
"shouldCloseLedger Trans="
45 << (anyTransactions ?
"yes" :
"no")
46 <<
" Prop: " << prevProposers <<
"/" << proposersClosed
47 <<
" Secs: " << timeSincePrevClose.
count()
48 <<
" (last: " << prevRoundTime.
count() <<
")";
52 if ((proposersClosed + proposersValidated) > (prevProposers / 2))
55 JLOG(j.
trace()) <<
"Others have closed";
62 return timeSincePrevClose >= idleInterval;
68 JLOG(j.
debug()) <<
"Must wait minimum time before closing";
75 if (openTime < (prevRoundTime / 2))
77 JLOG(j.
debug()) <<
"Ledger has not been open long enough";
115 std::size_t currentPercentage = (agreeing * 100) / total;
117 return currentPercentage >= minConsensusPct;
132 JLOG(j.
trace()) <<
"checkConsensus: prop=" << currentProposers <<
"/"
133 << prevProposers <<
" agree=" << currentAgree
134 <<
" validated=" << currentFinished
135 <<
" time=" << currentAgreeTime.
count() <<
"/"
137 <<
" minimum duration to reach consensus: "
139 <<
" max consensus time "
141 <<
" minimum consensus percentage: "
147 if (currentProposers < (prevProposers * 3 / 4))
153 JLOG(j.
trace()) <<
"too fast, not enough proposers";
167 JLOG(j.
debug()) <<
"normal consensus";
180 JLOG(j.
warn()) <<
"We see no consensus, but 80% of nodes have moved on";
185 JLOG(j.
trace()) <<
"no consensus";
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
ConsensusState checkConsensus(std::size_t prevProposers, std::size_t currentProposers, std::size_t currentAgree, std::size_t currentFinished, std::chrono::milliseconds previousAgreeTime, std::chrono::milliseconds currentAgreeTime, ConsensusParms const &parms, bool proposing, beast::Journal j)
Determine whether the network reached consensus and whether we joined.
@ proposing
We are normal participant in consensus and propose our position.
bool shouldCloseLedger(bool anyTransactions, std::size_t prevProposers, std::size_t proposersClosed, std::size_t proposersValidated, std::chrono::milliseconds prevRoundTime, std::chrono::milliseconds timeSincePrevClose, std::chrono::milliseconds openTime, std::chrono::milliseconds idleInterval, ConsensusParms const &parms, beast::Journal j)
Determines whether the current ledger should close at this time.
bool checkConsensusReached(std::size_t agreeing, std::size_t total, bool count_self, std::size_t minConsensusPct, bool reachedMax)
ConsensusState
Whether we have or don't have a consensus.
@ MovedOn
The network has consensus without us.
@ Yes
We have consensus along with the network.
@ No
We do not have consensus.
Consensus algorithm parameters.
std::size_t minCONSENSUS_PCT
The percentage threshold above which we can declare consensus.
std::chrono::milliseconds ledgerMIN_CONSENSUS
The number of seconds we wait minimum to ensure participation.
std::chrono::milliseconds ledgerMAX_CONSENSUS
The maximum amount of time to spend pausing for laggards.
std::chrono::milliseconds ledgerMIN_CLOSE
Minimum number of seconds to wait to ensure others have computed the LCL.