From 3d2aae9ea515807ff1fefc798469565c4e3f90f7 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 3 Nov 2015 13:55:54 -0800 Subject: [PATCH] Make close time consensus detection use montonic close time rules --- .../app/ledger/impl/LedgerConsensusImp.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index 5129d893b..185a87983 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -1551,8 +1551,10 @@ void LedgerConsensusImp::updateOurPositions () else { // proposal is still fresh - ++closeTimes[roundCloseTime ( - it->second->getCloseTime (), mCloseResolution)]; + ++closeTimes[std::max ( + roundCloseTime (it->second->getCloseTime (), + mCloseResolution), + mPreviousLedger->info().closeTime + 1)]; ++it; } } @@ -1604,16 +1606,20 @@ void LedgerConsensusImp::updateOurPositions () { // no other times mHaveCloseTimeConsensus = true; - closeTime = roundCloseTime ( - mOurPosition->getCloseTime (), mCloseResolution); + closeTime = std::max( + roundCloseTime (mOurPosition->getCloseTime (), + mCloseResolution), + mPreviousLedger->info().closeTime + 1); } else { int participants = mPeerPositions.size (); if (mProposing) { - ++closeTimes[roundCloseTime ( - mOurPosition->getCloseTime (), mCloseResolution)]; + ++closeTimes[std::max ( + roundCloseTime (mOurPosition->getCloseTime (), + mCloseResolution), + mPreviousLedger->info().closeTime + 1)]; ++participants; } @@ -1663,8 +1669,7 @@ void LedgerConsensusImp::updateOurPositions () } if (!changes && - ((closeTime != roundCloseTime ( - mOurPosition->getCloseTime (), mCloseResolution)) + ((closeTime != mOurPosition->getCloseTime ()) || mOurPosition->isStale (ourCutoff))) { // close time changed or our position is stale