Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
node
blockmanager_args.cpp
Go to the documentation of this file.
1
// Copyright (c) 2023-present 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
5
#include <
node/blockmanager_args.h
>
6
7
#include <
common/args.h
>
8
#include <
node/blockstorage.h
>
9
#include <
node/database_args.h
>
10
#include <
tinyformat.h
>
11
#include <
util/byte_units.h
>
12
#include <
util/result.h
>
13
#include <
util/translation.h
>
14
#include <validation.h>
15
16
#include <cstdint>
17
18
namespace
node
{
19
util::Result<void>
ApplyArgsManOptions
(
const
ArgsManager
&
args
,
BlockManager::Options
& opts)
20
{
21
if
(
auto
value{
args
.
GetBoolArg
(
"-blocksxor"
)}) opts.
use_xor
= *value;
22
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
23
int64_t nPruneArg{
args
.
GetIntArg
(
"-prune"
, opts.
prune_target
)};
24
if
(nPruneArg < 0) {
25
return
util::Error
{
_
(
"Prune cannot be configured with a negative value."
)};
26
}
27
uint64_t nPruneTarget{uint64_t(nPruneArg) * 1_MiB};
28
if
(nPruneArg == 1) {
// manual pruning: -prune=1
29
nPruneTarget =
BlockManager::PRUNE_TARGET_MANUAL
;
30
}
else
if
(nPruneTarget) {
31
if
(nPruneTarget <
MIN_DISK_SPACE_FOR_BLOCK_FILES
) {
32
return
util::Error
{
strprintf
(
_
(
"Prune configured below the minimum of %d MiB. Please use a higher number."
),
MIN_DISK_SPACE_FOR_BLOCK_FILES
/ 1_MiB)};
33
}
34
}
35
opts.
prune_target
= nPruneTarget;
36
37
if
(
auto
value{
args
.
GetBoolArg
(
"-fastprune"
)}) opts.
fast_prune
= *value;
38
39
ReadDatabaseArgs
(
args
, opts.
block_tree_db_params
.
options
);
40
41
return
{};
42
}
43
}
// namespace node
args.h
args
ArgsManager & args
Definition
bitcoind.cpp:280
blockmanager_args.h
blockstorage.h
byte_units.h
ArgsManager
Definition
args.h:107
ArgsManager::GetIntArg
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Definition
args.h:323
ArgsManager::GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return boolean argument or default value.
Definition
args.cpp:571
node::BlockManager::PRUNE_TARGET_MANUAL
static constexpr auto PRUNE_TARGET_MANUAL
Definition
blockstorage.h:409
node::BlockManager::Options
kernel::BlockManagerOpts Options
Definition
blockstorage.h:317
util::Result
Definition
result.h:36
database_args.h
node
Definition
messages.h:21
node::ApplyArgsManOptions
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
Definition
blockmanager_args.cpp:19
node::ReadDatabaseArgs
void ReadDatabaseArgs(const ArgsManager &args, DBOptions &options)
Definition
database_args.cpp:11
result.h
DBParams::options
DBOptions options
Passed-through options.
Definition
dbwrapper.h:57
kernel::BlockManagerOpts::prune_target
uint64_t prune_target
Definition
blockmanager_opts.h:27
kernel::BlockManagerOpts::block_tree_db_params
DBParams block_tree_db_params
Definition
blockmanager_opts.h:31
kernel::BlockManagerOpts::fast_prune
bool fast_prune
Definition
blockmanager_opts.h:28
kernel::BlockManagerOpts::use_xor
bool use_xor
Definition
blockmanager_opts.h:26
util::Error
Definition
result.h:15
tinyformat.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1172
translation.h
_
consteval auto _(util::TranslatedLiteral str)
Definition
translation.h:79
MIN_DISK_SPACE_FOR_BLOCK_FILES
constexpr uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Definition
validation.h:87
Generated on
for Bitcoin Core by
1.18.0