aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2024-02-08 11:37:19 -0500
committerRyan Ofsky <ryan@ofsky.org>2024-03-18 11:28:40 -0500
commit0fd915ee6bef63bb360ccc5c039a3c11676c38e3 (patch)
treed10c5ce4767a07fefcc6daf068456cea50ae94a2
parent63e8fc912c21a2f5b47e8eab10fb13c604afed85 (diff)
validation: Check GuessVerificationProgress is not called with disconnected block
Use Assume macro as suggested https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1479427801
-rw-r--r--src/validation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 94d2680db7..02f415101e 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -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;