validation: Check GuessVerificationProgress is not called with disconnected block

Use Assume macro as suggested https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1479427801
This commit is contained in:
Ryan Ofsky 2024-02-08 11:37:19 -05:00
parent 63e8fc912c
commit 0fd915ee6b
1 changed files with 6 additions and 0 deletions

View File

@ -5286,6 +5286,12 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin
if (pindex == nullptr)
return 0.0;
if (!Assume(pindex->nChainTx > 0)) {
LogWarning("Internal bug detected: block %d has unset nChainTx (%s %s). Please report this issue here: %s\n",
pindex->nHeight, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT);
return 0.0;
}
int64_t nNow = time(nullptr);
double fTxTotal;