mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 23:30:05 +02:00
validation: Don't add pruned blocks to m_blocks_unlinked on startup
LoadBlockIndex() adds to m_blocks_unlinked based only on nTx > 0, without checking BLOCK_HAVE_DATA. Pruning preserves nTx but clears BLOCK_HAVE_DATA, so a pruned block whose parent was header-only gets re-added on every restart, causing the CheckBlockIndex() assertion that entries must have data on disk to fail. Check that BLOCK_HAVE_DATA is set before inserting into m_blocks_unlinked. Fixes #35050.
This commit is contained in:
@@ -487,7 +487,9 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
|
||||
pindex->m_chain_tx_count = pindex->pprev->m_chain_tx_count + pindex->nTx;
|
||||
} else {
|
||||
pindex->m_chain_tx_count = 0;
|
||||
m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex));
|
||||
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
||||
m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pindex->m_chain_tx_count = pindex->nTx;
|
||||
|
||||
Reference in New Issue
Block a user