Skip to content

Commit 462390c

Browse files
committed
refactor: Move stopafterblockimport handling out of blockstorage
This has the benefit of moving the StartShutdown call out of the blockstorage file and thus out of the kernel's responsibility. The user can now decide if he wants to start shutdown / interrupt after a block import or not.
1 parent ef29d5d commit 462390c

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

src/init.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
#include <zmq/zmqrpc.h>
115115
#endif
116116

117-
using kernel::DEFAULT_STOPAFTERBLOCKIMPORT;
118117
using kernel::DumpMempool;
119118
using kernel::ValidationCacheSizes;
120119

@@ -136,6 +135,7 @@ using node::VerifyLoadedChainstate;
136135
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
137136
static constexpr bool DEFAULT_REST_ENABLE{false};
138137
static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true};
138+
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
139139

140140
#ifdef WIN32
141141
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
@@ -1653,6 +1653,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16531653
chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
16541654
// Import blocks
16551655
ImportBlocks(chainman, vImportFiles);
1656+
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
1657+
LogPrintf("Stopping after block import\n");
1658+
StartShutdown();
1659+
return;
1660+
}
1661+
16561662
// Start indexes initial sync
16571663
if (!StartIndexBackgroundSync(node)) {
16581664
bilingual_str err_str = _("Failed to start indexes, shutting down..");

src/kernel/blockmanager_opts.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class CChainParams;
1414

1515
namespace kernel {
1616

17-
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
18-
1917
/**
2018
* An options struct for `BlockManager`, more ergonomically referred to as
2119
* `BlockManager::Options` due to the using-declaration in `BlockManager`.
@@ -24,7 +22,6 @@ struct BlockManagerOpts {
2422
const CChainParams& chainparams;
2523
uint64_t prune_target{0};
2624
bool fast_prune{false};
27-
bool stop_after_block_import{DEFAULT_STOPAFTERBLOCKIMPORT};
2825
const fs::path blocks_dir;
2926
Notifications& notifications;
3027
};

src/node/blockmanager_args.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Op
3232
opts.prune_target = nPruneTarget;
3333

3434
if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value;
35-
if (auto value{args.GetBoolArg("-stopafterblockimport")}) opts.stop_after_block_import = *value;
3635

3736
return {};
3837
}

src/node/blockstorage.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -946,12 +946,6 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
946946
return;
947947
}
948948
}
949-
950-
if (chainman.m_blockman.StopAfterBlockImport()) {
951-
LogPrintf("Stopping after block import\n");
952-
StartShutdown();
953-
return;
954-
}
955949
} // End scope of ImportingNow
956950
}
957951
} // namespace node

src/node/blockstorage.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ class BlockManager
213213

214214
[[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; }
215215

216-
[[nodiscard]] bool StopAfterBlockImport() const { return m_opts.stop_after_block_import; }
217-
218216
/** Calculate the amount of disk space the block & undo files currently use */
219217
uint64_t CalculateCurrentUsage();
220218

0 commit comments

Comments
 (0)