20 #include <ripple/basics/Log.h>
21 #include <ripple/consensus/Consensus.h>
40 using namespace std::chrono_literals;
42 if ((prevRoundTime < -1s) || (prevRoundTime > 10min) ||
43 (timeSincePrevClose > 10min))
46 JLOG(j.
warn()) <<
"Trans=" << (anyTransactions ?
"yes" :
"no")
47 <<
" Prop: " << prevProposers <<
"/" << proposersClosed
48 <<
" Secs: " << timeSincePrevClose.
count()
49 <<
" (last: " << prevRoundTime.
count() <<
")";
53 if ((proposersClosed + proposersValidated) > (prevProposers / 2))
56 JLOG(j.
trace()) <<
"Others have closed";
64 openTime += *validationDelay;
69 return timeSincePrevClose >= idleInterval;
75 JLOG(j.
debug()) <<
"Must wait minimum time before closing";
82 if (openTime < (prevRoundTime / 2))
84 JLOG(j.
debug()) <<
"Ledger has not been open long enough";
109 std::size_t currentPercentage = (agreeing * 100) / total;
111 return currentPercentage >= minConsensusPct;
126 JLOG(j.
trace()) <<
"checkConsensus: prop=" << currentProposers <<
"/"
127 << prevProposers <<
" agree=" << currentAgree
128 <<
" validated=" << currentFinished
129 <<
" time=" << currentAgreeTime.
count() <<
"/"
130 << previousAgreeTime.
count();
132 if (currentProposers < (prevProposers * 3 / 4))
138 JLOG(j.
trace()) <<
"too fast, not enough proposers";
148 JLOG(j.
debug()) <<
"normal consensus";
157 JLOG(j.
warn()) <<
"We see no consensus, but 80% of nodes have moved on";
162 JLOG(j.
trace()) <<
"checkConsensus no consensus";
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.
ConsensusState
Whether we have or don't have a consensus.
@ proposing
We are normal participant in consensus and propose our position.
Stream trace() const
Severity stream access functions.
@ Yes
We have consensus along with the network.
bool checkConsensusReached(std::size_t agreeing, std::size_t total, bool count_self, std::size_t minConsensusPct)
std::size_t minCONSENSUS_PCT
The percentage threshold and floating point factor above which we can declare consensus.
std::chrono::milliseconds ledgerMIN_CLOSE
Minimum number of seconds to wait to ensure others have computed the LCL.
A generic endpoint for log messages.
@ No
We do not have consensus.
@ MovedOn
The network has consensus without us.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::chrono::milliseconds ledgerMIN_CONSENSUS
The number of seconds we wait minimum to ensure participation.
Consensus algorithm parameters.
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::optional< std::chrono::milliseconds > validationDelay, std::chrono::milliseconds idleInterval, ConsensusParms const &parms, beast::Journal j)
Determines whether the current ledger should close at this time.