From 11f7012d09d5963c7bd69e496752eed6b8f67125 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 15 Aug 2012 01:20:14 -0700 Subject: [PATCH] Fix a bug where tx set acquire timeouts never occured. Run acquire timeouts in milliseconds rather than seconds. --- src/LedgerAcquire.cpp | 8 +++++--- src/LedgerConsensus.cpp | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/LedgerAcquire.cpp b/src/LedgerAcquire.cpp index 6e13a883c8..1a7e6e8edf 100644 --- a/src/LedgerAcquire.cpp +++ b/src/LedgerAcquire.cpp @@ -11,12 +11,14 @@ #include "HashPrefixes.h" // #define LA_DEBUG -#define LEDGER_ACQUIRE_TIMEOUT 1 +#define LEDGER_ACQUIRE_TIMEOUT 750 #define TRUST_NETWORK PeerSet::PeerSet(const uint256& hash, int interval) : mHash(hash), mTimerInterval(interval), mTimeouts(0), mComplete(false), mFailed(false), mProgress(true), mTimer(theApp->getIOService()) -{ ; } +{ + assert((mTimerInterval > 10) && (mTimerInterval < 30000)); +} void PeerSet::peerHas(Peer::pointer ptr) { @@ -61,7 +63,7 @@ void PeerSet::badPeer(Peer::pointer ptr) void PeerSet::resetTimer() { - mTimer.expires_from_now(boost::posix_time::seconds(mTimerInterval)); + mTimer.expires_from_now(boost::posix_time::milliseconds(mTimerInterval)); mTimer.async_wait(boost::bind(&PeerSet::TimerEntry, pmDowncast(), boost::asio::placeholders::error)); } diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index aba77ea75f..5f34c7c344 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -13,11 +13,13 @@ #include "Log.h" #include "SHAMapSync.h" +#define TX_ACQUIRE_TIMEOUT 250 + #define TRUST_NETWORK // #define LC_DEBUG -TransactionAcquire::TransactionAcquire(const uint256& hash) : PeerSet(hash, 1), mHaveRoot(false) +TransactionAcquire::TransactionAcquire(const uint256& hash) : PeerSet(hash, TX_ACQUIRE_TIMEOUT), mHaveRoot(false) { mMap = boost::make_shared(); mMap->setSynching(); @@ -664,6 +666,7 @@ void LedgerConsensus::startAcquiring(TransactionAcquire::pointer acquire) } } } + acquire->resetTimer(); } void LedgerConsensus::propose(const std::vector& added, const std::vector& removed)