From d6f781f1cfcbc2c2ad5ee289a0642ed00386d013 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Thu, 16 Feb 2023 16:54:26 -0500 Subject: [PATCH] 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. --- src/node/chainstate.cpp | 1 + src/validation.cpp | 4 ++-- src/validation.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 245dfee14fc..7d6e0f3bb0e 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -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")}; diff --git a/src/validation.cpp b/src/validation.cpp index 29299a8eb3a..5a6db2674d8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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; } } diff --git a/src/validation.h b/src/validation.h index 7e30fc95de4..a9977e76e38 100644 --- a/src/validation.h +++ b/src/validation.h @@ -352,6 +352,7 @@ arith_uint256 CalculateHeadersWork(const std::vector& headers); enum class VerifyDBResult { SUCCESS, CORRUPTED_BLOCK_DB, + INTERRUPTED, }; /** RAII wrapper for VerifyDB: Verify consistency of the block and coin databases */