diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -118,7 +118,6 @@ using node::CleanupBlockRevFiles; using node::DEFAULT_PERSIST_MEMPOOL; using node::DEFAULT_STOPAFTERBLOCKIMPORT; -using node::fPruneMode; using node::fReindex; using node::LoadChainstate; using node::MempoolPath; diff --git a/src/node/blockmanager_args.cpp b/src/node/blockmanager_args.cpp --- a/src/node/blockmanager_args.cpp +++ b/src/node/blockmanager_args.cpp @@ -20,14 +20,12 @@ // manual pruning: -prune=1 if (nPruneArg == 1) { nPruneTarget = std::numeric_limits::max(); - fPruneMode = true; } else if (nPruneTarget) { if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { return strprintf(_("Prune configured below the minimum of %d MiB. " "Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024); } - fPruneMode = true; } opts.prune_target = nPruneTarget; diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -50,7 +50,6 @@ extern std::atomic_bool fImporting; extern std::atomic_bool fReindex; -extern bool fPruneMode; // Because validation code takes pointers to the map's CBlockIndex objects, if // we ever switch to another associative container, we need to either use a @@ -127,6 +126,8 @@ */ bool m_check_for_pruning = false; + const bool m_prune_mode; + /** Dirty block index entries. */ std::set m_dirty_blockindex; @@ -138,7 +139,8 @@ public: using Options = kernel::BlockManagerOpts; - explicit BlockManager(Options opts) : m_opts{std::move(opts)} {}; + explicit BlockManager(Options opts) + : m_prune_mode{opts.prune_target > 0}, m_opts{std::move(opts)} {}; BlockMap m_block_index GUARDED_BY(cs_main); @@ -192,7 +194,7 @@ const FlatFilePos *dbp); /** Whether running in -prune mode. */ - [[nodiscard]] bool IsPruneMode() const { return fPruneMode; } + [[nodiscard]] bool IsPruneMode() const { return m_prune_mode; } /** Attempt to stay below this number of bytes of block files. */ [[nodiscard]] uint64_t GetPruneTarget() const { diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -26,7 +26,6 @@ namespace node { std::atomic_bool fImporting(false); std::atomic_bool fReindex(false); -bool fPruneMode = false; static FILE *OpenUndoFile(const FlatFilePos &pos, bool fReadOnly = false); @@ -132,7 +131,7 @@ void BlockManager::FindFilesToPruneManual(std::set &setFilesToPrune, int nManualPruneHeight, int chain_tip_height) { - assert(fPruneMode && nManualPruneHeight > 0); + assert(IsPruneMode() && nManualPruneHeight > 0); LOCK2(cs_main, cs_LastBlockFile); if (chain_tip_height < 0) { @@ -644,7 +643,7 @@ return AbortNode("Disk space is too low!", _("Disk space is too low!")); } - if (bytes_allocated != 0 && fPruneMode) { + if (bytes_allocated != 0 && IsPruneMode()) { m_check_for_pruning = true; } } @@ -670,7 +669,7 @@ return AbortNode(state, "Disk space is too low!", _("Disk space is too low!")); } - if (bytes_allocated != 0 && fPruneMode) { + if (bytes_allocated != 0 && IsPruneMode()) { m_check_for_pruning = true; } diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -61,7 +61,6 @@ using node::ApplyArgsManOptions; using node::BlockAssembler; using node::CalculateCacheSizes; -using node::fPruneMode; using node::fReindex; using node::LoadChainstate; using node::NodeContext;