Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <common/args.h>
8#include <node/blockstorage.h>
9#include <tinyformat.h>
10#include <util/translation.h>
11#include <validation.h>
12
13#include <cstdint>
14#include <optional>
15
16namespace node {
17std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager &args,
19 // block pruning; get the amount of disk space (in MiB) to allot for block &
20 // undo files
21 int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
22 if (nPruneArg < 0) {
23 return _("Prune cannot be configured with a negative value.");
24 }
26 // manual pruning: -prune=1
27 if (nPruneArg == 1) {
29 } else if (nPruneTarget) {
31 return strprintf(_("Prune configured below the minimum of %d MiB. "
32 "Please use a higher number."),
33 MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024);
34 }
35 }
37
38 if (auto value{args.GetBoolArg("-fastprune")}) {
39 opts.fast_prune = *value;
40 }
41 if (auto value{args.GetBoolArg("-stopafterblockimport")}) {
42 opts.stop_after_block_import = *value;
43 }
44
45 return std::nullopt;
46}
47} // namespace node
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition args.cpp:526
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition args.cpp:556
static constexpr auto PRUNE_TARGET_MANUAL
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &argsman, const CChainParams &chainparams, MemPoolOptions &mempool_opts)
Overlay the options set in argsman on top of corresponding members in mempool_opts.
Definition init.h:28
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
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...
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:110