validation: return VerifyDBResult::INTERRUPTED if verification was interrupted

This means that the -verifydb RPC will now return false if it
cannot finish due to the node being shutdown.
This commit is contained in:
Martin Zumsande 2023-02-16 16:54:26 -05:00
parent 6360b5302d
commit d6f781f1cf
3 changed files with 4 additions and 2 deletions

View File

@ -193,6 +193,7 @@ ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const C
options.check_blocks);
switch (result) {
case VerifyDBResult::SUCCESS:
case VerifyDBResult::INTERRUPTED:
break;
case VerifyDBResult::CORRUPTED_BLOCK_DB:
return {ChainstateLoadStatus::FAILURE, _("Corrupted block database detected")};

View File

@ -4146,7 +4146,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
skipped_l3_checks = true;
}
}
if (ShutdownRequested()) return VerifyDBResult::SUCCESS;
if (ShutdownRequested()) return VerifyDBResult::INTERRUPTED;
}
if (pindexFailure) {
LogPrintf("Verification error: coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", chainstate.m_chain.Height() - pindexFailure->nHeight + 1, nGoodTransactions);
@ -4179,7 +4179,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
LogPrintf("Verification error: found unconnectable block at %d, hash=%s (%s)\n", pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
return VerifyDBResult::CORRUPTED_BLOCK_DB;
}
if (ShutdownRequested()) return VerifyDBResult::SUCCESS;
if (ShutdownRequested()) return VerifyDBResult::INTERRUPTED;
}
}

View File

@ -352,6 +352,7 @@ arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers);
enum class VerifyDBResult {
SUCCESS,
CORRUPTED_BLOCK_DB,
INTERRUPTED,
};
/** RAII wrapper for VerifyDB: Verify consistency of the block and coin databases */