Bitcoin ABC  0.26.3
P2P Digital Currency
blockmanager_args.cpp
Go to the documentation of this file.
1 // Copyright (c) 2023 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
7 #include <util/system.h>
8 #include <validation.h>
9 
10 namespace node {
11 std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager &args,
12  BlockManager::Options &opts) {
13  // block pruning; get the amount of disk space (in MiB) to allot for block &
14  // undo files
15  int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
16  if (nPruneArg < 0) {
17  return _("Prune cannot be configured with a negative value.");
18  }
19  uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
20  // manual pruning: -prune=1
21  if (nPruneArg == 1) {
22  nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
23  } else if (nPruneTarget) {
24  if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
25  return strprintf(_("Prune configured below the minimum of %d MiB. "
26  "Please use a higher number."),
27  MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024);
28  }
29  }
30  opts.prune_target = nPruneTarget;
31 
32  return std::nullopt;
33 }
34 } // namespace node
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: system.cpp:635
static constexpr auto PRUNE_TARGET_MANUAL
Definition: blockstorage.h:204
Definition: init.h:28
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
An options struct for BlockManager, more ergonomically referred to as BlockManager::Options due to th...
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:68
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev?...
Definition: validation.h:111