Changeset View
Changeset View
Standalone View
Standalone View
src/script/scriptcache.cpp
Show All 14 Lines | |||||
static CuckooCache::cache<uint256, SignatureCacheHasher> scriptExecutionCache; | static CuckooCache::cache<uint256, SignatureCacheHasher> scriptExecutionCache; | ||||
static uint256 scriptExecutionCacheNonce(GetRandHash()); | static uint256 scriptExecutionCacheNonce(GetRandHash()); | ||||
void InitScriptExecutionCache() { | void InitScriptExecutionCache() { | ||||
// nMaxCacheSize is unsigned. If -maxscriptcachesize is set to zero, | // nMaxCacheSize is unsigned. If -maxscriptcachesize is set to zero, | ||||
// setup_bytes creates the minimum possible cache (2 elements). | // setup_bytes creates the minimum possible cache (2 elements). | ||||
size_t nMaxCacheSize = | size_t nMaxCacheSize = | ||||
std::min(std::max(int64_t(0), | std::min( | ||||
gArgs.GetArg("-maxscriptcachesize", | std::max(int64_t(0), gArgs.GetArg("-maxscriptcachesize", | ||||
DEFAULT_MAX_SCRIPT_CACHE_SIZE)), | DEFAULT_MAX_SCRIPT_CACHE_SIZE)), | ||||
MAX_MAX_SCRIPT_CACHE_SIZE) * | MAX_MAX_SCRIPT_CACHE_SIZE) * | ||||
(size_t(1) << 20); | (size_t(1) << 20); | ||||
size_t nElems = scriptExecutionCache.setup_bytes(nMaxCacheSize); | size_t nElems = scriptExecutionCache.setup_bytes(nMaxCacheSize); | ||||
LogPrintf("Using %zu MiB out of %zu requested for script execution cache, " | LogPrintf("Using %zu MiB out of %zu requested for script execution cache, " | ||||
"able to store %zu elements\n", | "able to store %zu elements\n", | ||||
(nElems * sizeof(uint256)) >> 20, nMaxCacheSize >> 20, nElems); | (nElems * sizeof(uint256)) >> 20, nMaxCacheSize >> 20, nElems); | ||||
} | } | ||||
uint256 GetScriptCacheKey(const CTransaction &tx, uint32_t flags) { | uint256 GetScriptCacheKey(const CTransaction &tx, uint32_t flags) { | ||||
Show All 27 Lines |