20 #include <ripple/basics/Log.h>
21 #include <ripple/consensus/Consensus.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";
102 std::size_t currentPercentage = (agreeing * 100) / total;
104 return currentPercentage >= minConsensusPct;
119 JLOG(j.
trace()) <<
"checkConsensus: prop=" << currentProposers <<
"/"
120 << prevProposers <<
" agree=" << currentAgree
121 <<
" validated=" << currentFinished
122 <<
" time=" << currentAgreeTime.
count() <<
"/"
123 << previousAgreeTime.
count();
128 if (currentProposers < (prevProposers * 3 / 4))
134 JLOG(j.
trace()) <<
"too fast, not enough proposers";
144 JLOG(j.
debug()) <<
"normal consensus";
153 JLOG(j.
warn()) <<
"We see no consensus, but 80% of nodes have moved on";
158 JLOG(j.
trace()) <<
"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.
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.
@ 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 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.