From e2137ea5af8de50f66dce7047bb00c6e1dbac561 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 8 Sep 2012 03:49:12 -0700 Subject: [PATCH] Make our ledger a bit stickier to avoid the "check at the wrong time" problem (when you don't have enough validations for the latest ledger and so jump backwards when you shouldn't. This solves every known ledger consensus issue except the "stuck one ledger behind" issue. I'm working on that now. --- src/LedgerConsensus.cpp | 5 +---- src/NetworkOPs.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index bdba1c7da4..802810f681 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -247,10 +247,7 @@ void LedgerConsensus::checkLCL() uint256 netLgr = mPrevLedgerHash; int netLgrCount = 0; - uint256 favorLedger; - if (mState != lcsPRE_CLOSE) - favorLedger = mPrevLedgerHash; - boost::unordered_map vals = theApp->getValidations().getCurrentValidations(favorLedger); + boost::unordered_map vals = theApp->getValidations().getCurrentValidations(mPrevLedgerHash); typedef std::pair u256_int_pair; BOOST_FOREACH(u256_int_pair& it, vals) diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 7706cd7ac9..754559db83 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -446,18 +446,18 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector& peerLis // node is using. THis is kind of fundamental. Log(lsTRACE) << "NetworkOPs::checkLastClosedLedger"; - boost::unordered_map ledgers; + Ledger::pointer ourClosed = mLedgerMaster->getClosedLedger(); + uint256 closedLedger = ourClosed->getHash(); + uint256 prevClosedLedger = ourClosed->getParentHash(); + boost::unordered_map ledgers; { - boost::unordered_map current = theApp->getValidations().getCurrentValidations(); + boost::unordered_map current = theApp->getValidations().getCurrentValidations(closedLedger); typedef std::pair u256_int_pair; BOOST_FOREACH(u256_int_pair& it, current) ledgers[it.first].trustedValidations += it.second; } - Ledger::pointer ourClosed = mLedgerMaster->getClosedLedger(); - uint256 closedLedger = ourClosed->getHash(); - uint256 prevClosedLedger = ourClosed->getParentHash(); ValidationCount& ourVC = ledgers[closedLedger]; if ((theConfig.LEDGER_CREATOR) && (mMode >= omTRACKING))