From 6553b21318587e78d5796cf75f189c52c15b0c93 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 6 Aug 2012 03:05:35 -0700 Subject: [PATCH] Fix some dead ledger logic. --- src/ValidationCollection.cpp | 14 +++++++++++--- src/ValidationCollection.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ValidationCollection.cpp b/src/ValidationCollection.cpp index 21888dffad..466b3d7f2e 100644 --- a/src/ValidationCollection.cpp +++ b/src/ValidationCollection.cpp @@ -14,7 +14,7 @@ bool ValidationCollection::addValidation(SerializedValidation::pointer val) val->setTrusted(); uint32 now = theApp->getOPs().getCloseTimeNC(); uint32 valClose = val->getCloseTime(); - if ((now > valClose) && (now < (valClose + LEDGER_MAX_INTERVAL))) + if ((now > (valClose - 4)) && (now < (valClose + LEDGER_MAX_INTERVAL))) isCurrent = true; else Log(lsWARNING) << "Received stale validation now=" << now << ", close=" << valClose; @@ -172,11 +172,19 @@ boost::unordered_map ValidationCollection::getCurrentValidations() return ret; } -void ValidationCollection::addDeadLedger(const uint256& ledger) +bool ValidationCollection::isDeadLedger(const uint256& ledger) { for (std::list::iterator it = mDeadLedgers.begin(), end = mDeadLedgers.end(); it != end; ++it) if (*it == ledger) - return; + return true; + return false; +} + +void ValidationCollection::addDeadLedger(const uint256& ledger) +{ + if (isDeadLedger(ledger)) + return; + mDeadLedgers.push_back(ledger); if (mDeadLedgers.size() >= 128) mDeadLedgers.pop_front(); diff --git a/src/ValidationCollection.h b/src/ValidationCollection.h index 5f58956bc6..2198a967fe 100644 --- a/src/ValidationCollection.h +++ b/src/ValidationCollection.h @@ -48,6 +48,7 @@ public: boost::unordered_map getCurrentValidations(); void addDeadLedger(const uint256&); + bool isDeadLedger(const uint256&); std::list getDeadLedgers() { return mDeadLedgers; } void flush();