diff --git a/src/cpp/ripple/LedgerConsensus.cpp b/src/cpp/ripple/LedgerConsensus.cpp index ac09032f7..d4fc7d97f 100644 --- a/src/cpp/ripple/LedgerConsensus.cpp +++ b/src/cpp/ripple/LedgerConsensus.cpp @@ -373,9 +373,12 @@ void LedgerConsensus::checkLCL() uint256 netLgr = mPrevLedgerHash; int netLgrCount = 0; - uint256 favoredLedger = mPrevLedgerHash; // Don't get stuck one ledger back or jump one forward + uint256 favoredLedger = mPrevLedgerHash; // Don't jump forward + uint256 priorLedger; + if (mHaveCorrectLCL) + priorLedger = mPreviousLedger->getParentHash(); // don't jump back boost::unordered_map vals = - theApp->getValidations().getCurrentValidations(favoredLedger); + theApp->getValidations().getCurrentValidations(favoredLedger, priorLedger); typedef std::map::value_type u256_cvc_pair; BOOST_FOREACH(u256_cvc_pair& it, vals) diff --git a/src/cpp/ripple/LedgerTiming.h b/src/cpp/ripple/LedgerTiming.h index c7539c081..246db51cf 100644 --- a/src/cpp/ripple/LedgerTiming.h +++ b/src/cpp/ripple/LedgerTiming.h @@ -7,11 +7,11 @@ // The number of seconds a validation remains current after its ledger's close time // This is a safety to protect against very old validations and the time it takes to adjust // the close time accuracy window -# define LEDGER_VAL_INTERVAL 600 +# define LEDGER_VAL_INTERVAL 300 // The number of seconds before a close time that we consider a validation acceptable // This protects against extreme clock errors -# define LEDGER_EARLY_INTERVAL 240 +# define LEDGER_EARLY_INTERVAL 180 // The number of milliseconds we wait minimum to ensure participation # define LEDGER_MIN_CONSENSUS 2000 diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 742e630f1..9bc3745b6 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -685,7 +685,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector& peerLis boost::unordered_map ledgers; { boost::unordered_map current = - theApp->getValidations().getCurrentValidations(closedLedger); + theApp->getValidations().getCurrentValidations(closedLedger, prevClosedLedger); typedef std::map::value_type u256_cvc_pair; BOOST_FOREACH(const u256_cvc_pair& it, current) { diff --git a/src/cpp/ripple/ValidationCollection.cpp b/src/cpp/ripple/ValidationCollection.cpp index acb8c3157..cdbb2818e 100644 --- a/src/cpp/ripple/ValidationCollection.cpp +++ b/src/cpp/ripple/ValidationCollection.cpp @@ -228,10 +228,11 @@ std::list ValidationCollection::getCurrentTrusted } boost::unordered_map -ValidationCollection::getCurrentValidations(uint256 currentLedger) +ValidationCollection::getCurrentValidations(uint256 currentLedger, uint256 priorLedger) { uint32 cutoff = theApp->getOPs().getNetworkTimeNC() - LEDGER_VAL_INTERVAL; bool valCurrentLedger = currentLedger.isNonZero(); + bool valPriorLedger = priorLedger.isNonZero(); boost::unordered_map ret; @@ -250,7 +251,8 @@ ValidationCollection::getCurrentValidations(uint256 currentLedger) } else { // contains a live record - bool countPreferred = valCurrentLedger && it->second->isPreviousHash(currentLedger); + bool countPreferred = (valCurrentLedger && it->second->isPreviousHash(currentLedger)) || + (valPriorLedger && (it->second->getLedgerHash() == priorLedger)); tLog(countPreferred, lsDEBUG) << "Counting for " << currentLedger << " not " << it->second->getLedgerHash(); currentValidationCount& p = countPreferred ? ret[currentLedger] : ret[it->second->getLedgerHash()]; diff --git a/src/cpp/ripple/ValidationCollection.h b/src/cpp/ripple/ValidationCollection.h index bcde16aa2..112e9c111 100644 --- a/src/cpp/ripple/ValidationCollection.h +++ b/src/cpp/ripple/ValidationCollection.h @@ -47,7 +47,9 @@ public: int getNodesAfter(const uint256& ledger); int getLoadRatio(bool overLoaded); - boost::unordered_map getCurrentValidations(uint256 currentLedger); + boost::unordered_map getCurrentValidations( + uint256 currentLedger, uint256 previousLedger); + std::list getCurrentTrustedValidations(); void tune(int size, int age);