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.
This commit is contained in:
JoelKatz
2016-04-27 17:03:25 -07:00
committed by Vinnie Falco
parent 3f84dd8cf9
commit 0efb929898

View File

@@ -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 "