mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
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:
@@ -695,6 +695,15 @@ public:
|
|||||||
if (isCurrent)
|
if (isCurrent)
|
||||||
mLedgerHistory.addLedger(ledger, true);
|
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);
|
ledger->pendSaveValidated (isSynchronous, isCurrent);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,8 +152,21 @@ bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger)
|
|||||||
// comes before the last validated ledger (and thus has been
|
// comes before the last validated ledger (and thus has been
|
||||||
// validated).
|
// validated).
|
||||||
auto hash = ledgerMaster.walkHashBySeq (seq);
|
auto hash = ledgerMaster.walkHashBySeq (seq);
|
||||||
|
|
||||||
if (ledger.info().hash != hash)
|
if (ledger.info().hash != hash)
|
||||||
|
{
|
||||||
|
// This ledger's hash is not the hash of the validated ledger
|
||||||
|
if (hash.isNonZero ())
|
||||||
|
{
|
||||||
|
uint256 valHash = Ledger::getHashByIndex (seq);
|
||||||
|
if (valHash == ledger.info().hash)
|
||||||
|
{
|
||||||
|
// SQL database doesn't match ledger chain
|
||||||
|
ledgerMaster.clearLedger (seq);
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SHAMapMissingNode const&)
|
catch (SHAMapMissingNode const&)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user