LCOV - code coverage report
Current view: top level - src/node - validation_cache_args.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 3 8 37.5 %
Date: 2023-11-06 23:13:05 Functions: 1 1 100.0 %
Branches: 3 6 50.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/validation_cache_args.h>
       6                 :            : 
       7                 :            : #include <kernel/validation_cache_sizes.h>
       8                 :            : 
       9                 :            : #include <common/args.h>
      10                 :            : 
      11                 :            : #include <algorithm>
      12                 :            : #include <cstddef>
      13                 :            : #include <cstdint>
      14                 :            : #include <memory>
      15                 :            : #include <optional>
      16                 :            : 
      17                 :            : using kernel::ValidationCacheSizes;
      18                 :            : 
      19                 :            : namespace node {
      20                 :          1 : void ApplyArgsManOptions(const ArgsManager& argsman, ValidationCacheSizes& cache_sizes)
      21                 :            : {
      22 [ +  - ][ +  - ]:          1 :     if (auto max_size = argsman.GetIntArg("-maxsigcachesize")) {
                 [ +  - ]
      23                 :            :         // 1. When supplied with a max_size of 0, both InitSignatureCache and
      24                 :            :         //    InitScriptExecutionCache create the minimum possible cache (2
      25                 :            :         //    elements). Therefore, we can use 0 as a floor here.
      26                 :            :         // 2. Multiply first, divide after to avoid integer truncation.
      27                 :          0 :         size_t clamped_size_each = std::max<int64_t>(*max_size, 0) * (1 << 20) / 2;
      28                 :          0 :         cache_sizes = {
      29                 :          0 :             .signature_cache_bytes = clamped_size_each,
      30                 :          0 :             .script_execution_cache_bytes = clamped_size_each,
      31                 :            :         };
      32                 :          0 :     }
      33                 :          1 : }
      34                 :            : } // namespace node

Generated by: LCOV version 1.14