LCOV - code coverage report
Current view: top level - src/node - chainstatemanager_args.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 21 0.0 %
Date: 2024-01-03 14:57:27 Functions: 0 1 0.0 %
Branches: 0 65 0.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2022 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/chainstatemanager_args.h>
       6                 :            : 
       7                 :            : #include <arith_uint256.h>
       8                 :            : #include <common/args.h>
       9                 :            : #include <common/system.h>
      10                 :            : #include <logging.h>
      11                 :            : #include <node/coins_view_args.h>
      12                 :            : #include <node/database_args.h>
      13                 :            : #include <tinyformat.h>
      14                 :            : #include <uint256.h>
      15                 :            : #include <util/result.h>
      16                 :            : #include <util/strencodings.h>
      17                 :            : #include <util/translation.h>
      18                 :            : #include <validation.h>
      19                 :            : 
      20                 :            : #include <algorithm>
      21                 :            : #include <chrono>
      22                 :            : #include <string>
      23                 :            : 
      24                 :            : namespace node {
      25                 :          0 : util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
      26                 :            : {
      27 [ #  # ][ #  # ]:          0 :     if (auto value{args.GetBoolArg("-checkblockindex")}) opts.check_block_index = *value;
                 [ #  # ]
      28                 :            : 
      29 [ #  # ][ #  # ]:          0 :     if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
                 [ #  # ]
      30                 :            : 
      31 [ #  # ][ #  # ]:          0 :     if (auto value{args.GetArg("-minimumchainwork")}) {
                 [ #  # ]
              [ #  #  # ]
      32 [ #  # ][ #  # ]:          0 :         if (!IsHexNumber(*value)) {
      33 [ #  # ][ #  # ]:          0 :             return util::Error{strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), *value)};
         [ #  # ][ #  # ]
      34                 :            :         }
      35 [ #  # ][ #  # ]:          0 :         opts.minimum_chain_work = UintToArith256(uint256S(*value));
                 [ #  # ]
      36                 :          0 :     }
      37                 :            : 
      38 [ #  # ][ #  # ]:          0 :     if (auto value{args.GetArg("-assumevalid")}) opts.assumed_valid_block = uint256S(*value);
         [ #  # ][ #  # ]
      39                 :            : 
      40 [ #  # ][ #  # ]:          0 :     if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
                 [ #  # ]
      41                 :            : 
      42                 :          0 :     ReadDatabaseArgs(args, opts.block_tree_db);
      43                 :          0 :     ReadDatabaseArgs(args, opts.coins_db);
      44                 :          0 :     ReadCoinsViewArgs(args, opts.coins_view);
      45                 :            : 
      46 [ #  # ][ #  # ]:          0 :     int script_threads = args.GetIntArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
      47         [ #  # ]:          0 :     if (script_threads <= 0) {
      48                 :            :         // -par=0 means autodetect (number of cores - 1 script threads)
      49                 :            :         // -par=-n means "leave n cores free" (number of cores - n - 1 script threads)
      50                 :          0 :         script_threads += GetNumCores();
      51                 :          0 :     }
      52                 :            :     // Subtract 1 because the main thread counts towards the par threads.
      53                 :          0 :     opts.worker_threads_num = std::clamp(script_threads - 1, 0, MAX_SCRIPTCHECK_THREADS);
      54 [ #  # ][ #  # ]:          0 :     LogPrintf("Script verification uses %d additional threads\n", opts.worker_threads_num);
                 [ #  # ]
      55                 :            : 
      56                 :          0 :     return {};
      57                 :          0 : }
      58                 :            : } // namespace node

Generated by: LCOV version 1.14