aboutsummaryrefslogtreecommitdiff
path: root/src/node/validation_cache_args.cpp
blob: ed183c24fe678c47cc62e24e0bfaf8a5565c2285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <node/validation_cache_args.h>

#include <kernel/validation_cache_sizes.h>

#include <util/system.h>

#include <memory>
#include <optional>

using kernel::ValidationCacheSizes;

namespace node {
void ApplyArgsManOptions(const ArgsManager& argsman, ValidationCacheSizes& cache_sizes)
{
    if (auto max_size = argsman.GetIntArg("-maxsigcachesize")) {
        // Multiply first, divide after to avoid integer truncation
        int64_t size_each = *max_size * (1 << 20) / 2;
        cache_sizes = {
            .signature_cache_bytes = size_each,
            .script_execution_cache_bytes = size_each,
        };
    }
}
} // namespace node