LCOV - code coverage report
Current view: top level - src/node - blockmanager_args.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 78.6 % 14 11
Test Date: 2026-04-27 06:44:50 Functions: 100.0 % 1 1
Branches: 43.8 % 16 7

             Branch data     Line data    Source code
       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                 :         669 : util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts)
      20                 :             : {
      21   [ +  -  -  + ]:        1338 :     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                 :        1338 :     int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
      24         [ -  + ]:         669 :     if (nPruneArg < 0) {
      25                 :           0 :         return util::Error{_("Prune cannot be configured with a negative value.")};
      26                 :             :     }
      27                 :         669 :     uint64_t nPruneTarget{uint64_t(nPruneArg) * 1_MiB};
      28         [ +  - ]:         669 :     if (nPruneArg == 1) { // manual pruning: -prune=1
      29                 :             :         nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
      30         [ -  + ]:         669 :     } else if (nPruneTarget) {
      31         [ #  # ]:           0 :         if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
      32                 :           0 :             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                 :         669 :     opts.prune_target = nPruneTarget;
      36                 :             : 
      37   [ +  -  -  + ]:        1338 :     if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value;
      38                 :             : 
      39                 :         669 :     ReadDatabaseArgs(args, opts.block_tree_db_params.options);
      40                 :             : 
      41                 :         669 :     return {};
      42                 :             : }
      43                 :             : } // namespace node
        

Generated by: LCOV version 2.0-1