aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/init.cpp1
-rw-r--r--src/node/blockmanager_args.cpp2
-rw-r--r--src/node/blockstorage.cpp7
-rw-r--r--src/node/blockstorage.h9
4 files changed, 9 insertions, 10 deletions
diff --git a/src/init.cpp b/src/init.cpp
index d68ba80b79..8a45c38ce3 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -123,7 +123,6 @@ using node::ShouldPersistMempool;
using node::NodeContext;
using node::ThreadImport;
using node::VerifyLoadedChainstate;
-using node::fPruneMode;
using node::fReindex;
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
diff --git a/src/node/blockmanager_args.cpp b/src/node/blockmanager_args.cpp
index cba44dafb9..876d5d2e57 100644
--- a/src/node/blockmanager_args.cpp
+++ b/src/node/blockmanager_args.cpp
@@ -18,12 +18,10 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, BlockM
uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
if (nPruneArg == 1) { // manual pruning: -prune=1
nPruneTarget = std::numeric_limits<uint64_t>::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.cpp b/src/node/blockstorage.cpp
index 5e364942d4..4d2d5daf05 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -28,7 +28,6 @@
namespace node {
std::atomic_bool fImporting(false);
std::atomic_bool fReindex(false);
-bool fPruneMode = false;
bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const
{
@@ -153,7 +152,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
void BlockManager::FindFilesToPruneManual(std::set<int>& 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) {
@@ -656,7 +655,7 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
if (out_of_space) {
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;
}
}
@@ -680,7 +679,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
if (out_of_space) {
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/node/blockstorage.h b/src/node/blockstorage.h
index d76d916a93..78ca727c99 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -49,7 +49,6 @@ static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = CMessageHeader::MESSAG
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
@@ -124,6 +123,8 @@ private:
*/
bool m_check_for_pruning = false;
+ const bool m_prune_mode;
+
/** Dirty block index entries. */
std::set<CBlockIndex*> m_dirty_blockindex;
@@ -143,7 +144,9 @@ private:
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);
@@ -187,7 +190,7 @@ public:
FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, 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 { return m_opts.prune_target; }