diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 83dcbefefe..bb56dcde9c 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -259,7 +259,7 @@ void LedgerConsensus::checkLCL() uint256 netLgr = mPrevLedgerHash; int netLgrCount = 0; - uint256 favoredLedger = (mState == lcsPRE_CLOSE) ? uint256() : mPrevLedgerHash; // Don't get stuck one ledger behind + uint256 favoredLedger = (mState == lcsPRE_CLOSE) ? uint256() : mPrevLedgerHash; // Don't get stuck one ledger back boost::unordered_map vals = theApp->getValidations().getCurrentValidations(favoredLedger); @@ -287,15 +287,18 @@ void LedgerConsensus::checkLCL() << status << ", " << (mHaveCorrectLCL ? "CorrectLCL" : "IncorrectLCL"); cLog(lsWARNING) << mPrevLedgerHash << " to " << netLgr; -#ifdef DEBUG - BOOST_FOREACH(u256_cvc_pair& it, vals) - cLog(lsDEBUG) << "V: " << it.first << ", " << it.second.first; -#endif + if (sLog(lsDEBUG)) + { + BOOST_FOREACH(u256_cvc_pair& it, vals) + cLog(lsDEBUG) << "V: " << it.first << ", " << it.second.first; + } if (mHaveCorrectLCL) theApp->getOPs().consensusViewChange(); handleLCL(netLgr); } + else if (mPreviousLedger->getHash() != mPrevLedgerHash) + handleLCL(netLgr); } void LedgerConsensus::handleLCL(const uint256& lclHash) @@ -810,7 +813,9 @@ void LedgerConsensus::propose() { cLog(lsTRACE) << "We propose: " << mOurPosition->getCurrentHash(); ripple::TMProposeSet prop; + prop.set_currenttxhash(mOurPosition->getCurrentHash().begin(), 256 / 8); + prop.set_previousledger(mOurPosition->getPrevLedger().begin(), 256 / 8); prop.set_proposeseq(mOurPosition->getProposeSeq()); prop.set_closetime(mOurPosition->getCloseTime()); @@ -958,18 +963,12 @@ void LedgerConsensus::Saccept(boost::shared_ptr This, SHAMap::p This->accept(txSet); } -void LedgerConsensus::deferProposal(const LedgerProposal::pointer& proposal, const NewcoinAddress& peerPublic) -{ - std::list& props = mDeferredProposals[peerPublic.getNodeID()]; - if (props.size() >= (mPreviousProposers + 10)) - props.pop_front(); - props.push_back(proposal); -} - void LedgerConsensus::playbackProposals() { + boost::unordered_map >& storedProposals = theApp->getOPs().peekStoredProposals(); for (boost::unordered_map< uint160, std::list >::iterator - it = mDeferredProposals.begin(), end = mDeferredProposals.end(); it != end; ++it) + it = storedProposals.begin(), end = storedProposals.end(); it != end; ++it) { BOOST_FOREACH(const LedgerProposal::pointer& proposal, it->second) { @@ -978,7 +977,7 @@ void LedgerConsensus::playbackProposals() proposal->setPrevLedger(mPrevLedgerHash); if (proposal->checkSign()) { - cLog(lsINFO) << "Applying deferred proposal"; + cLog(lsINFO) << "Applying stored proposal"; peerPosition(proposal); } } diff --git a/src/LedgerConsensus.h b/src/LedgerConsensus.h index ffe8db5d3c..a88aee0792 100644 --- a/src/LedgerConsensus.h +++ b/src/LedgerConsensus.h @@ -113,9 +113,6 @@ protected: // Close time estimates std::map mCloseTimes; - // deferred proposals (node ID -> proposals from that peer) - boost::unordered_map< uint160, std::list > mDeferredProposals; - // nodes that have bowed out of this consensus process boost::unordered_set mDeadNodes; @@ -180,16 +177,12 @@ public: bool haveConsensus(); bool peerPosition(const LedgerProposal::pointer&); - void deferProposal(const LedgerProposal::pointer& proposal, const NewcoinAddress& peerPublic); bool peerHasSet(Peer::ref peer, const uint256& set, ripple::TxSetStatus status); bool peerGaveNodes(Peer::ref peer, const uint256& setHash, const std::list& nodeIDs, const std::list< std::vector >& nodeData); - void swapDefer(boost::unordered_map< uint160, std::list > &n) - { mDeferredProposals.swap(n); } - // test/debug void simulate(); }; diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 931364054f..9698bbbc57 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -57,7 +57,7 @@ protected: boost::asio::deadline_timer mNetTimer; boost::shared_ptr mConsensus; boost::unordered_map > mDeferredProposals; + std::list > mStoredProposals; LedgerMaster* mLedgerMaster; LedgerAcquire::pointer mAcquiringLedger; @@ -193,6 +193,9 @@ public: void setLastCloseTime(uint32 t) { mLastCloseTime = t; } Json::Value getServerInfo(); uint32 acceptLedger(); + boost::unordered_map >& peekStoredProposals() { return mStoredProposals; } + void storeProposal(const LedgerProposal::pointer& proposal, const NewcoinAddress& peerPublic); // client information retrieval functions std::vector< std::pair >