aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2023-05-05 15:54:13 -0400
committerJames O'Beirne <james.obeirne@pm.me>2023-09-30 06:40:17 -0400
commit4c3b8ca35c2e4a441264749bb312df2bd054b5b8 (patch)
treec0a671b1c728c3039f08a103713fa5d9a930b836 /src/validation.cpp
parent49ef778158c43859946a592e11ec34fe1b93a5b6 (diff)
downloadbitcoin-4c3b8ca35c2e4a441264749bb312df2bd054b5b8.tar.xz
validation: populate nChainTx value for assumedvalid chainstates
Use the expected AssumeutxoData in order to bootstrap nChainTx values for assumedvalid blockindex entries in the snapshot chainstate. This is necessary because nChainTx is normally built up from nTx values, which are populated using blockdata which the snapshot chainstate does not yet have.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index b5cff0a4fd..9c783ece65 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4542,7 +4542,7 @@ bool ChainstateManager::LoadBlockIndex()
// Load block index from databases
bool needs_init = fReindex;
if (!fReindex) {
- bool ret{m_blockman.LoadBlockIndexDB()};
+ bool ret{m_blockman.LoadBlockIndexDB(SnapshotBlockhash())};
if (!ret) return false;
m_blockman.ScanAndUnlinkAlreadyPrunedFiles();
@@ -4838,6 +4838,10 @@ void ChainstateManager::CheckBlockIndex()
CBlockIndex* pindexFirstAssumeValid = nullptr; // Oldest ancestor of pindex which has BLOCK_ASSUMED_VALID
while (pindex != nullptr) {
nNodes++;
+ if (pindex->pprev && pindex->nTx > 0) {
+ // nChainTx should increase monotonically
+ assert(pindex->pprev->nChainTx <= pindex->nChainTx);
+ }
if (pindexFirstAssumeValid == nullptr && pindex->nStatus & BLOCK_ASSUMED_VALID) pindexFirstAssumeValid = pindex;
if (pindexFirstInvalid == nullptr && pindex->nStatus & BLOCK_FAILED_VALID) pindexFirstInvalid = pindex;
if (pindexFirstMissing == nullptr && !(pindex->nStatus & BLOCK_HAVE_DATA)) {