mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
validationcaches: Use size_t for sizes
...also move the 0-clamping logic to ApplyArgsManOptions, where it belongs.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user