diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-03-15 16:10:24 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-03-15 16:02:47 +0100 |
commit | fadf8b818226dc60adf88e927160f9c9680473a4 (patch) | |
tree | 4c25bb80d307be3e50de20f5b1ee634cc1135bc0 | |
parent | fa9bd7be472f49b15f5f87711094095954322635 (diff) |
refactor: Add and use PRUNE_TARGET_MANUAL constexpr
-rw-r--r-- | src/node/blockmanager_args.cpp | 2 | ||||
-rw-r--r-- | src/node/blockstorage.h | 1 | ||||
-rw-r--r-- | src/node/chainstate.cpp | 2 | ||||
-rw-r--r-- | src/rpc/blockchain.cpp | 4 |
4 files changed, 4 insertions, 5 deletions
diff --git a/src/node/blockmanager_args.cpp b/src/node/blockmanager_args.cpp index 876d5d2e57..5fb5c8beed 100644 --- a/src/node/blockmanager_args.cpp +++ b/src/node/blockmanager_args.cpp @@ -17,7 +17,7 @@ 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(); + 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. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024); diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index de9b1c0bb5..5ba0045b8b 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -195,6 +195,7 @@ public: /** Attempt to stay below this number of bytes of block files. */ [[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; } + static constexpr auto PRUNE_TARGET_MANUAL{std::numeric_limits<uint64_t>::max()}; [[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; } diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 125d6de5a5..cfd3472592 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -169,7 +169,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) { LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex()); } - if (chainman.m_blockman.GetPruneTarget() == std::numeric_limits<uint64_t>::max()) { + if (chainman.m_blockman.GetPruneTarget() == BlockManager::PRUNE_TARGET_MANUAL) { LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n"); } else if (chainman.m_blockman.GetPruneTarget()) { LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", chainman.m_blockman.GetPruneTarget() / 1024 / 1024); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5afa460075..1a9b265fbe 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1249,7 +1249,6 @@ RPCHelpMan getblockchaininfo() }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { - const ArgsManager& args{EnsureAnyArgsman(request.context)}; ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); Chainstate& active_chainstate = chainman.ActiveChainstate(); @@ -1272,8 +1271,7 @@ RPCHelpMan getblockchaininfo() if (chainman.m_blockman.IsPruneMode()) { obj.pushKV("pruneheight", chainman.m_blockman.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", chainman.m_blockman.GetPruneTarget()); |