mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +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};
|
uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
|
||||||
if (nPruneArg == 1) { // manual pruning: -prune=1
|
if (nPruneArg == 1) { // manual pruning: -prune=1
|
||||||
nPruneTarget = std::numeric_limits<uint64_t>::max();
|
nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
|
||||||
} else if (nPruneTarget) {
|
} else if (nPruneTarget) {
|
||||||
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
|
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);
|
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. */
|
/** Attempt to stay below this number of bytes of block files. */
|
||||||
[[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; }
|
[[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; }
|
[[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)) {
|
if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
|
||||||
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
|
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");
|
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
|
||||||
} else if (chainman.m_blockman.GetPruneTarget()) {
|
} 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);
|
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 RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
const ArgsManager& args{EnsureAnyArgsman(request.context)};
|
|
||||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
Chainstate& active_chainstate = chainman.ActiveChainstate();
|
||||||
|
@ -1272,8 +1271,7 @@ RPCHelpMan getblockchaininfo()
|
||||||
if (chainman.m_blockman.IsPruneMode()) {
|
if (chainman.m_blockman.IsPruneMode()) {
|
||||||
obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight);
|
obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight);
|
||||||
|
|
||||||
// if 0, execution bypasses the whole if block.
|
const bool automatic_pruning{chainman.m_blockman.GetPruneTarget() != BlockManager::PRUNE_TARGET_MANUAL};
|
||||||
bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
|
|
||||||
obj.pushKV("automatic_pruning", automatic_pruning);
|
obj.pushKV("automatic_pruning", automatic_pruning);
|
||||||
if (automatic_pruning) {
|
if (automatic_pruning) {
|
||||||
obj.pushKV("prune_target_size", chainman.m_blockman.GetPruneTarget());
|
obj.pushKV("prune_target_size", chainman.m_blockman.GetPruneTarget());
|
||||||
|
|
Loading…
Add table
Reference in a new issue