Remove a ledger from the set of present ledgers where needed

* If we encounter it in RPC
* If we fully-validate a ledger that doesn't have it in its history
This commit is contained in:
JoelKatz
2015-07-27 14:38:06 -07:00
committed by Nik Bougalis
parent f0dc2bc425
commit cfdf0d2f0a
2 changed files with 22 additions and 0 deletions

View File

@@ -695,6 +695,15 @@ public:
if (isCurrent)
mLedgerHistory.addLedger(ledger, true);
{
// Check the SQL database's entry for the sequence before this ledger,
// if it's not this ledger's parent, invalidate it
uint256 prevHash = Ledger::getHashByIndex (ledger->info().seq - 1);
if (prevHash.isNonZero () && (prevHash != ledger->info().parentHash))
clearLedger (ledger->info().seq - 1);
}
ledger->pendSaveValidated (isSynchronous, isCurrent);
{