mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 09:25:51 +00:00
Improve the way we declare a close time consensus
This commit is contained in:
@@ -1522,6 +1522,14 @@ private:
|
|||||||
propose ();
|
propose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For a given number of participants and required percent
|
||||||
|
// for consensus, how many participants must agree?
|
||||||
|
static int computePercent (int size, int percent)
|
||||||
|
{
|
||||||
|
int result = ((size * percent) + (percent / 2)) / 100;
|
||||||
|
return (result == 0) ? 1 : result;
|
||||||
|
}
|
||||||
|
|
||||||
void updateOurPositions ()
|
void updateOurPositions ()
|
||||||
{
|
{
|
||||||
boost::posix_time::ptime peerCutoff
|
boost::posix_time::ptime peerCutoff
|
||||||
@@ -1609,28 +1617,18 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Threshold for non-zero vote
|
int participants = mPeerPositions.size ();
|
||||||
int threshVote = mPeerPositions.size ();
|
|
||||||
// Threshold to declare consensus
|
|
||||||
int threshConsensus = mPeerPositions.size ();
|
|
||||||
|
|
||||||
if (mProposing)
|
if (mProposing)
|
||||||
{
|
{
|
||||||
++closeTimes[roundCloseTime (mOurPosition->getCloseTime ())];
|
++closeTimes[roundCloseTime (mOurPosition->getCloseTime ())];
|
||||||
++threshVote;
|
++participants;
|
||||||
++threshConsensus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
threshVote = ((threshVote * neededWeight) + (neededWeight / 2))
|
// Threshold for non-zero vote
|
||||||
/ 100;
|
int threshVote = computePercent (participants, neededWeight);
|
||||||
threshConsensus = ((threshConsensus * AV_CT_CONSENSUS_PCT)
|
|
||||||
+ (AV_CT_CONSENSUS_PCT / 2)) / 100;
|
|
||||||
|
|
||||||
if (threshVote == 0)
|
// Threshold to declare consensus
|
||||||
threshVote = 1;
|
int threshConsensus = computePercent (participants, AV_CT_CONSENSUS_PCT);
|
||||||
|
|
||||||
if (threshConsensus == 0)
|
|
||||||
threshConsensus = 1;
|
|
||||||
|
|
||||||
WriteLog (lsINFO, LedgerConsensus) << "Proposers:"
|
WriteLog (lsINFO, LedgerConsensus) << "Proposers:"
|
||||||
<< mPeerPositions.size () << " nw:" << neededWeight
|
<< mPeerPositions.size () << " nw:" << neededWeight
|
||||||
@@ -1656,6 +1654,13 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we agree to disagree on the close time, don't delay consensus
|
||||||
|
if (!mHaveCloseTimeConsensus && (closeTimes[0] > threshConsensus))
|
||||||
|
{
|
||||||
|
closeTime = 0;
|
||||||
|
mHaveCloseTimeConsensus = true;
|
||||||
|
}
|
||||||
|
|
||||||
CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus)
|
CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConsensus)
|
||||||
<< "No CT consensus: Proposers:" << mPeerPositions.size ()
|
<< "No CT consensus: Proposers:" << mPeerPositions.size ()
|
||||||
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:"
|
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:"
|
||||||
|
|||||||
Reference in New Issue
Block a user