aboutsummaryrefslogtreecommitdiff
path: root/src/node/blockstorage.cpp
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2021-04-18 16:48:52 +0200
committerFabian Jahr <fjahr@protonmail.com>2022-04-25 23:18:01 +0200
commit231fc7b035481f748159968353c1cab81354e843 (patch)
tree4b04c9911342bd54b070a567c9eda6dec9a1efc0 /src/node/blockstorage.cpp
parent1e7db37e76c510d373c4404eea2b97508b367aca (diff)
downloadbitcoin-231fc7b035481f748159968353c1cab81354e843.tar.xz
refactor: Introduce GetFirstStoredBlock helper function
Diffstat (limited to 'src/node/blockstorage.cpp')
-rw-r--r--src/node/blockstorage.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 21cb0250d8..c3f42fde2d 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -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