aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2022-07-01 00:08:14 -0400
committerCarl Dong <contact@carldong.me>2022-08-03 12:03:28 -0400
commit0f3a2532c38074dd9789d1c4c667db6ca46ff0ab (patch)
treee45ce50c4efda6ac38aa3dfeeb18dae4e2ecc8d0 /src/validation.cpp
parent41c5201a90bbc2893333e334e8945759ef24e7dd (diff)
downloadbitcoin-0f3a2532c38074dd9789d1c4c667db6ca46ff0ab.tar.xz
validationcaches: Use size_t for sizes
...also move the 0-clamping logic to ApplyArgsManOptions, where it belongs.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 7a03adf558..c924bb3c34 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1656,7 +1656,7 @@ bool CScriptCheck::operator()() {
static CuckooCache::cache<uint256, SignatureCacheHasher> g_scriptExecutionCache;
static CSHA256 g_scriptExecutionCacheHasher;
-bool InitScriptExecutionCache(int64_t max_size_bytes)
+bool InitScriptExecutionCache(size_t max_size_bytes)
{
// Setup the salted hasher
uint256 nonce = GetRandHash();
@@ -1665,11 +1665,8 @@ bool InitScriptExecutionCache(int64_t max_size_bytes)
// just write our 32-byte entropy twice to fill the 64 bytes.
g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
- // nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
- // setup_bytes creates the minimum possible cache (2 elements).
- size_t nMaxCacheSize = std::max<int64_t>(max_size_bytes, 0);
- auto setup_results = g_scriptExecutionCache.setup_bytes(nMaxCacheSize);
+ auto setup_results = g_scriptExecutionCache.setup_bytes(max_size_bytes);
if (!setup_results) return false;
const auto [num_elems, approx_size_bytes] = *setup_results;