Skip to content

Commit fadf8b8

Browse files
author
MarcoFalke
committed
refactor: Add and use PRUNE_TARGET_MANUAL constexpr
1 parent fa9bd7b commit fadf8b8

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/node/blockmanager_args.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, BlockM
1717
}
1818
uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
1919
if (nPruneArg == 1) { // manual pruning: -prune=1
20-
nPruneTarget = std::numeric_limits<uint64_t>::max();
20+
nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
2121
} else if (nPruneTarget) {
2222
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
2323
return strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024);

src/node/blockstorage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class BlockManager
195195

196196
/** Attempt to stay below this number of bytes of block files. */
197197
[[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; }
198+
static constexpr auto PRUNE_TARGET_MANUAL{std::numeric_limits<uint64_t>::max()};
198199

199200
[[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; }
200201

src/node/chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
169169
if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
170170
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
171171
}
172-
if (chainman.m_blockman.GetPruneTarget() == std::numeric_limits<uint64_t>::max()) {
172+
if (chainman.m_blockman.GetPruneTarget() == BlockManager::PRUNE_TARGET_MANUAL) {
173173
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
174174
} else if (chainman.m_blockman.GetPruneTarget()) {
175175
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", chainman.m_blockman.GetPruneTarget() / 1024 / 1024);

src/rpc/blockchain.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ RPCHelpMan getblockchaininfo()
12491249
},
12501250
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
12511251
{
1252-
const ArgsManager& args{EnsureAnyArgsman(request.context)};
12531252
ChainstateManager& chainman = EnsureAnyChainman(request.context);
12541253
LOCK(cs_main);
12551254
Chainstate& active_chainstate = chainman.ActiveChainstate();
@@ -1272,8 +1271,7 @@ RPCHelpMan getblockchaininfo()
12721271
if (chainman.m_blockman.IsPruneMode()) {
12731272
obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight);
12741273

1275-
// if 0, execution bypasses the whole if block.
1276-
bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
1274+
const bool automatic_pruning{chainman.m_blockman.GetPruneTarget() != BlockManager::PRUNE_TARGET_MANUAL};
12771275
obj.pushKV("automatic_pruning", automatic_pruning);
12781276
if (automatic_pruning) {
12791277
obj.pushKV("prune_target_size", chainman.m_blockman.GetPruneTarget());

0 commit comments

Comments
 (0)