From 89518e23cc8cfd00c8fbfd140f5f4cec7d420148 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 17 Sep 2012 00:38:47 -0700 Subject: [PATCH] Fix two more race conditions involving us taking our position late. Remove an incorrect comment. --- src/LedgerConsensus.cpp | 9 +++++++-- src/LedgerConsensus.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 48b26bdc12..0745329de7 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -358,13 +358,18 @@ void LedgerConsensus::takeInitialPosition(Ledger& initialLedger) SHAMap::pointer initialSet = initialLedger.peekTransactionMap()->snapShot(false); uint256 txSet = initialSet->getHash(); Log(lsINFO) << "initial position " << txSet; + mapComplete(txSet, initialSet, false); if (mValidating) mOurPosition = boost::make_shared (mValSeed, initialLedger.getParentHash(), txSet, mCloseTime); else mOurPosition = boost::make_shared(initialLedger.getParentHash(), txSet, mCloseTime); - mapComplete(txSet, initialSet, false); + + BOOST_FOREACH(u256_lct_pair& it, mDisputes) + { + it.second->setOurVote(initialLedger.hasTransaction(it.first)); + } // if any peers have taken a contrary position, process disputes boost::unordered_set found; @@ -372,7 +377,7 @@ void LedgerConsensus::takeInitialPosition(Ledger& initialLedger) { uint256 set = it.second->getCurrentHash(); if (found.insert(set).second) - { // OPTIMIZEME: Don't process the same set more than once + { boost::unordered_map::iterator iit = mAcquired.find(set); if (iit != mAcquired.end()) createDisputes(initialSet, iit->second); diff --git a/src/LedgerConsensus.h b/src/LedgerConsensus.h index 3833c300b3..44b4db409f 100644 --- a/src/LedgerConsensus.h +++ b/src/LedgerConsensus.h @@ -62,6 +62,7 @@ public: const uint256& getTransactionID() const { return mTransactionID; } bool getOurVote() const { return mOurVote; } Serializer& peekTransaction() { return transaction; } + void setOurVote(bool o) { mOurVote = o; } void setVote(const uint160& peer, bool votesYes); void unVote(const uint160& peer);