diff --git a/src/ValidationCollection.cpp b/src/ValidationCollection.cpp index 21888dffa..466b3d7f2 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 5f58956bc..2198a967f 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();