From 0efb929898270fbebf036cab36902cddb32889ee Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 27 Apr 2016 17:03:25 -0700 Subject: [PATCH] Fix history acquire check (RIPD-1112) The various history acquire conditions were not combined properly, resulting in historical ledgers being acquired in cases where they should not be. --- src/ripple/app/ledger/impl/LedgerMaster.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index f2911465f4..db1b571213 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -1560,9 +1560,12 @@ LedgerMaster::shouldAcquire ( std::uint32_t const ledgerHistoryIndex, std::uint32_t const candidateLedger) const { - bool ret (candidateLedger >= currentLedger || - candidateLedger > ledgerHistoryIndex || - (currentLedger - candidateLedger) <= ledgerHistory); + // If the ledger could be the current ledger acquire it. + // Otherwise, acquire it only if it's within our range of + // desired history and we wouldn't delete it if we had it. + bool ret = (candidateLedger >= currentLedger) || + ((candidateLedger >= ledgerHistoryIndex) && + ((currentLedger - candidateLedger) <= ledgerHistory)); JLOG (m_journal.trace()) << "Missing ledger "