validationcaches: Use size_t for sizes

...also move the 0-clamping logic to ApplyArgsManOptions, where it
   belongs.
This commit is contained in:
Carl Dong
2022-07-01 00:08:14 -04:00
parent 41c5201a90
commit 0f3a2532c3
7 changed files with 20 additions and 21 deletions

View File

@@ -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;