Skip to content

Commit 57ba59c

Browse files
committed
refactor: Remove redundant reindex check
The check for whether the block tree db has been wiped before calling NeedsRedownload() is confusing. The boolean is set in case of a reindex. It was originally introduced to guard NeedsRedownload in case of a reindex in #21009. However NeedsRedownload already returns early if the chain's tip is not loaded. Since that is the case during a reindex, the pre-check is redundant.
1 parent df8bf65 commit 57ba59c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/node/chainstate.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,12 @@ static ChainstateLoadResult CompleteChainstateInitialization(
155155
}
156156
}
157157

158-
if (!options.wipe_block_tree_db) {
159-
auto chainstates{chainman.GetAll()};
160-
if (std::any_of(chainstates.begin(), chainstates.end(),
161-
[](const Chainstate* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
162-
return {ChainstateLoadStatus::FAILURE, strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."),
163-
chainman.GetConsensus().SegwitHeight)};
164-
};
165-
}
158+
auto chainstates{chainman.GetAll()};
159+
if (std::any_of(chainstates.begin(), chainstates.end(),
160+
[](const Chainstate* cs) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return cs->NeedsRedownload(); })) {
161+
return {ChainstateLoadStatus::FAILURE, strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."),
162+
chainman.GetConsensus().SegwitHeight)};
163+
};
166164

167165
// Now that chainstates are loaded and we're able to flush to
168166
// disk, rebalance the coins caches to desired levels based

0 commit comments

Comments
 (0)