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 @@ -19,7 +19,7 @@ uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024}; // manual pruning: -prune=1 if (nPruneArg == 1) { - nPruneTarget = std::numeric_limits::max(); + nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL; } else if (nPruneTarget) { if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { return strprintf(_("Prune configured below the minimum of %d MiB. " diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -201,6 +201,8 @@ [[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; } + static constexpr auto PRUNE_TARGET_MANUAL{ + std::numeric_limits::max()}; [[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; } diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -177,7 +177,7 @@ chainman.GetConsensus().nMinimumChainWork.GetHex()); } if (chainman.m_blockman.GetPruneTarget() == - std::numeric_limits::max()) { + BlockManager::PRUNE_TARGET_MANUAL) { LogPrintf( "Block pruning enabled. Use RPC call pruneblockchain(height) to " "manually prune block and undo files.\n"); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1337,7 +1337,6 @@ const JSONRPCRequest &request) -> UniValue { const CChainParams &chainparams = config.GetChainParams(); - const ArgsManager &args{EnsureAnyArgsman(request.context)}; ChainstateManager &chainman = EnsureAnyChainman(request.context); LOCK(cs_main); Chainstate &active_chainstate = chainman.ActiveChainstate(); @@ -1370,8 +1369,9 @@ obj.pushKV("pruneheight", node::GetFirstStoredBlock(&tip)->nHeight); - // if 0, execution bypasses the whole if block. - bool automatic_pruning{args.GetIntArg("-prune", 0) != 1}; + const bool automatic_pruning{ + chainman.m_blockman.GetPruneTarget() != + BlockManager::PRUNE_TARGET_MANUAL}; obj.pushKV("automatic_pruning", automatic_pruning); if (automatic_pruning) { obj.pushKV("prune_target_size",