Coverage Report

Created: 2025-06-10 13:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/node/blockmanager_args.cpp
Line
Count
Source
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
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/result.h>
12
#include <util/translation.h>
13
#include <validation.h>
14
15
#include <cstdint>
16
17
namespace node {
18
util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts)
19
22.1k
{
20
22.1k
    if (auto value{args.GetBoolArg("-blocksxor")}) opts.use_xor = *value;
  Branch (20:14): [True: 0, False: 22.1k]
21
    // block pruning; get the amount of disk space (in MiB) to allot for block & undo files
22
22.1k
    int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
23
22.1k
    if (nPruneArg < 0) {
  Branch (23:9): [True: 0, False: 22.1k]
24
0
        return util::Error{_("Prune cannot be configured with a negative value.")};
25
0
    }
26
22.1k
    uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
27
22.1k
    if (nPruneArg == 1) { // manual pruning: -prune=1
  Branch (27:9): [True: 0, False: 22.1k]
28
0
        nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
29
22.1k
    } else if (nPruneTarget) {
  Branch (29:16): [True: 0, False: 22.1k]
30
0
        if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
  Branch (30:13): [True: 0, False: 0]
31
0
            return util::Error{strprintf(_("Prune configured below the minimum of %d MiB.  Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)};
32
0
        }
33
0
    }
34
22.1k
    opts.prune_target = nPruneTarget;
35
36
22.1k
    if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value;
  Branch (36:14): [True: 0, False: 22.1k]
37
38
22.1k
    ReadDatabaseArgs(args, opts.block_tree_db_params.options);
39
40
22.1k
    return {};
41
22.1k
}
42
} // namespace node