mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
refactor: Introduce GetFirstStoredBlock helper function
This commit is contained in:
@@ -397,6 +397,16 @@ bool BlockManager::IsBlockPruned(const CBlockIndex* pblockindex)
|
||||
return (m_have_pruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0);
|
||||
}
|
||||
|
||||
const CBlockIndex* GetFirstStoredBlock(const CBlockIndex* start_block) {
|
||||
AssertLockHeld(::cs_main);
|
||||
assert(start_block);
|
||||
const CBlockIndex* last_block = start_block;
|
||||
while (last_block->pprev && (last_block->pprev->nStatus & BLOCK_HAVE_DATA)) {
|
||||
last_block = last_block->pprev;
|
||||
}
|
||||
return last_block;
|
||||
}
|
||||
|
||||
// If we're using -prune with -reindex, then delete block files that will be ignored by the
|
||||
// reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
|
||||
// is missing, do the same here to delete any later block files after a gap. Also delete all
|
||||
|
||||
Reference in New Issue
Block a user