aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2024-05-17 23:33:25 +0200
committerTheCharlatan <seb.kung@gmail.com>2024-07-04 22:39:37 +0200
commit13a3661aba95b54b822c99ecbb695b14a22536d2 (patch)
tree560db9184bf7eeb72994f64a3bc7f3f1a616dc4b /src/node
parentab14d1d6a4a8ef5fe5013150e6c5ebcb5f5e4ea9 (diff)
downloadbitcoin-13a3661aba95b54b822c99ecbb695b14a22536d2.tar.xz
kernel: De-globalize script execution 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.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/chainstatemanager_args.cpp9
-rw-r--r--src/node/validation_cache_args.cpp1
2 files changed, 9 insertions, 1 deletions
diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp
index bc4a815a3e..14dd8cd97b 100644
--- a/src/node/chainstatemanager_args.cpp
+++ b/src/node/chainstatemanager_args.cpp
@@ -56,6 +56,15 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
opts.worker_threads_num = std::clamp(script_threads - 1, 0, MAX_SCRIPTCHECK_THREADS);
LogPrintf("Script verification uses %d additional threads\n", opts.worker_threads_num);
+ if (auto max_size = args.GetIntArg("-maxsigcachesize")) {
+ // 1. When supplied with a max_size of 0, both the signature cache and
+ // script execution cache 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;
+ opts.script_execution_cache_bytes = clamped_size_each;
+ }
+
return {};
}
} // namespace node
diff --git a/src/node/validation_cache_args.cpp b/src/node/validation_cache_args.cpp
index ddf24f798d..b491dd9b37 100644
--- a/src/node/validation_cache_args.cpp
+++ b/src/node/validation_cache_args.cpp
@@ -27,7 +27,6 @@ void ApplyArgsManOptions(const ArgsManager& argsman, ValidationCacheSizes& cache
size_t clamped_size_each = std::max<int64_t>(*max_size, 0) * (1 << 20) / 2;
cache_sizes = {
.signature_cache_bytes = clamped_size_each,
- .script_execution_cache_bytes = clamped_size_each,
};
}
}