aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2024-06-07 12:12:34 +0200
committerTheCharlatan <seb.kung@gmail.com>2024-06-07 19:17:11 +0200
commit804f09dfa116300914e2aeef05ed9710dd504e8c (patch)
tree9dccb9bfec7e6a08dd6036e29b60b958bec67db6 /src/init.cpp
parente17255322378076edce3ef6f06cd36ca58d2e236 (diff)
kernel: Add less confusing reindex options
Drop confusing kernel options: BlockManagerOpts::reindex ChainstateLoadOptions::reindex ChainstateLoadOptions::reindex_chainstate Replacing them with more straightforward options: ChainstateLoadOptions::wipe_block_tree_db ChainstateLoadOptions::wipe_chainstate_db Having two options called "reindex" which did slightly different things was needlessly confusing (one option wiped the block tree database, and the other caused block files to be rescanned). Also the previous set of options did not allow rebuilding the block database without also rebuilding the chainstate database, when it should be possible to do those independently.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 343e23280a..fe69393795 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1482,7 +1482,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node.notifications = std::make_unique<KernelNotifications>(*Assert(node.shutdown), node.exit_status);
ReadNotificationArgs(args, *node.notifications);
- bool fReindexChainState = args.GetBoolArg("-reindex-chainstate", false);
ChainstateManager::Options chainman_opts{
.chainparams = chainparams,
.datadir = args.GetDataDirNet(),
@@ -1531,6 +1530,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
LogPrintf("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", cache_sizes.coins * (1.0 / 1024 / 1024), mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));
+ bool do_reindex{args.GetBoolArg("-reindex", false)};
+ const bool do_reindex_chainstate{args.GetBoolArg("-reindex-chainstate", false)};
+
for (bool fLoaded = false; !fLoaded && !ShutdownRequested(node);) {
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
@@ -1558,8 +1560,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node::ChainstateLoadOptions options;
options.mempool = Assert(node.mempool.get());
- options.reindex = blockman_opts.reindex;
- options.reindex_chainstate = fReindexChainState;
+ options.wipe_block_tree_db = do_reindex;
+ options.wipe_chainstate_db = do_reindex || do_reindex_chainstate;
options.prune = chainman.m_blockman.IsPruneMode();
options.check_blocks = args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
options.check_level = args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL);
@@ -1600,13 +1602,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (!fLoaded && !ShutdownRequested(node)) {
// first suggest a reindex
- if (!blockman_opts.reindex) {
+ if (!do_reindex) {
bool fRet = uiInterface.ThreadSafeQuestion(
error + Untranslated(".\n\n") + _("Do you want to rebuild the block database now?"),
error.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
if (fRet) {
- blockman_opts.reindex = true;
+ do_reindex = true;
if (!Assert(node.shutdown)->reset()) {
LogPrintf("Internal error: failed to reset shutdown signal.\n");
}
@@ -1694,7 +1696,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
int chain_active_height = WITH_LOCK(cs_main, return chainman.ActiveChain().Height());
// On first startup, warn on low block storage space
- if (!chainman.m_blockman.m_reindexing && !fReindexChainState && chain_active_height <= 1) {
+ if (!do_reindex && !do_reindex_chainstate && chain_active_height <= 1) {
uint64_t assumed_chain_bytes{chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
uint64_t additional_bytes_needed{
chainman.m_blockman.IsPruneMode() ?