mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
refactor: Add and use PRUNE_TARGET_MANUAL constexpr
This commit is contained in:
parent
fa9bd7be47
commit
fadf8b8182
4 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Reference in a new issue