aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2024-05-18 11:18:44 +0200
committerTheCharlatan <seb.kung@gmail.com>2024-07-05 09:03:04 +0200
commit606a7ab862470413ced400aa68a94fd37c8ad3d3 (patch)
tree73755b6bff7552069b60d1ab9f1c739bdde42bbe /src/node
parent66d74bfc45ae0f743084475ac3bbfb4355bb6ec2 (diff)
downloadbitcoin-606a7ab862470413ced400aa68a94fd37c8ad3d3.tar.xz
kernel: De-globalize signature cache
Move its ownership to the ChainstateManager class. Next to simplifying usage of the kernel library by no longer requiring manual setup of the cache prior to using validation code, it also slims down the amount of memory allocated by BasicTestingSetup. Use this opportunity to make SignatureCache RAII styled Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src/node')
-rw-r--r--src/node/chainstatemanager_args.cpp1
-rw-r--r--src/node/validation_cache_args.cpp33
-rw-r--r--src/node/validation_cache_args.h17
3 files changed, 1 insertions, 50 deletions
diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp
index 14dd8cd97b..39b5f3ad3e 100644
--- a/src/node/chainstatemanager_args.cpp
+++ b/src/node/chainstatemanager_args.cpp
@@ -63,6 +63,7 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
// 2. Multiply first, divide after to avoid integer truncation.
size_t clamped_size_each = std::max<int64_t>(*max_size, 0) * (1 << 20) / 2;
opts.script_execution_cache_bytes = clamped_size_each;
+ opts.signature_cache_bytes = clamped_size_each;
}
return {};
diff --git a/src/node/validation_cache_args.cpp b/src/node/validation_cache_args.cpp
deleted file mode 100644
index b491dd9b37..0000000000
--- a/src/node/validation_cache_args.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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 <common/args.h>
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <memory>
-#include <optional>
-
-using kernel::ValidationCacheSizes;
-
-namespace node {
-void ApplyArgsManOptions(const ArgsManager& argsman, ValidationCacheSizes& cache_sizes)
-{
- if (auto max_size = argsman.GetIntArg("-maxsigcachesize")) {
- // 1. When supplied with a max_size of 0, both InitSignatureCache and
- // InitScriptExecutionCache create the minimum possible cache (2
- // elements). Therefore, we can use 0 as a floor here.
- // 2. Multiply first, divide after to avoid integer truncation.
- size_t clamped_size_each = std::max<int64_t>(*max_size, 0) * (1 << 20) / 2;
- cache_sizes = {
- .signature_cache_bytes = clamped_size_each,
- };
- }
-}
-} // namespace node
diff --git a/src/node/validation_cache_args.h b/src/node/validation_cache_args.h
deleted file mode 100644
index f447c13b49..0000000000
--- a/src/node/validation_cache_args.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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.
-
-#ifndef BITCOIN_NODE_VALIDATION_CACHE_ARGS_H
-#define BITCOIN_NODE_VALIDATION_CACHE_ARGS_H
-
-class ArgsManager;
-namespace kernel {
-struct ValidationCacheSizes;
-};
-
-namespace node {
-void ApplyArgsManOptions(const ArgsManager& argsman, kernel::ValidationCacheSizes& cache_sizes);
-} // namespace node
-
-#endif // BITCOIN_NODE_VALIDATION_CACHE_ARGS_H