Skip to content

Commit 698c524

Browse files
committed
index: Fix backwards search for bestblock
This allows filters to be reconstructed when the best known block is the Genesis block without needing to reindex. It fixes Init errors seen in #23289.
1 parent 111c3e0 commit 698c524

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index/base.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ bool BaseIndex::Init()
9191
const CBlockIndex* block = active_chain.Tip();
9292
prune_violation = true;
9393
// check backwards from the tip if we have all block data until we reach the indexes bestblock
94-
while (block_to_test && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
94+
while (block_to_test && block && (block->nStatus & BLOCK_HAVE_DATA)) {
9595
if (block_to_test == block) {
9696
prune_violation = false;
9797
break;
9898
}
99+
assert(block->pprev);
99100
block = block->pprev;
100101
}
101102
}

0 commit comments

Comments
 (0)