LCOV - code coverage report
Current view: top level - src/node - blockmanager_args.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 12 17 70.6 %
Date: 2023-10-05 12:38:51 Functions: 4 4 100.0 %
Branches: 10 28 35.7 %

           Branch data     Line data    Source code
       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 <tinyformat.h>
      10                 :            : #include <util/result.h>
      11                 :            : #include <util/translation.h>
      12                 :            : #include <validation.h>
      13                 :            : 
      14                 :            : #include <cstdint>
      15                 :            : 
      16                 :            : namespace node {
      17         [ +  - ]:          3 : util::Result<void> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts)
      18         [ +  - ]:          2 : {
      19                 :            :     // block pruning; get the amount of disk space (in MiB) to allot for block & undo files
      20   [ +  -  +  - ]:          1 :     int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
      21         [ +  - ]:          1 :     if (nPruneArg < 0) {
      22         [ #  # ]:          0 :         return util::Error{_("Prune cannot be configured with a negative value.")};
      23                 :            :     }
      24                 :          1 :     uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
      25         [ -  + ]:          1 :     if (nPruneArg == 1) { // manual pruning: -prune=1
      26                 :          0 :         nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
      27         [ +  - ]:          1 :     } else if (nPruneTarget) {
      28         [ #  # ]:          0 :         if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
      29   [ #  #  #  # ]:          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)};
      30                 :            :         }
      31                 :          0 :     }
      32                 :          1 :     opts.prune_target = nPruneTarget;
      33                 :            : 
      34   [ +  -  +  -  :          1 :     if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value;
                   +  - ]
      35                 :            : 
      36                 :          1 :     return {};
      37                 :          1 : }
      38                 :            : } // namespace node

Generated by: LCOV version 1.14