Changeset View
Changeset View
Standalone View
Standalone View
src/script/scriptcache.cpp
Show All 20 Lines | void InitScriptExecutionCache() { | ||||
// 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(std::max(int64_t(0), | ||||
gArgs.GetArg("-maxscriptcachesize", | 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, " | LogPrint(BCLog::SCRIPT, | ||||
"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) { | ||||
uint256 key; | uint256 key; | ||||
// We only use the first 19 bytes of nonce to avoid a second SHA round - | // We only use the first 19 bytes of nonce to avoid a second SHA round - | ||||
// giving us 19 + 32 + 4 = 55 bytes (+ 8 + 1 = 64) | // giving us 19 + 32 + 4 = 55 bytes (+ 8 + 1 = 64) | ||||
static_assert(55 - sizeof(flags) - 32 >= 128 / 8, | static_assert(55 - sizeof(flags) - 32 >= 128 / 8, | ||||
"Want at least 128 bits of nonce for script execution cache"); | "Want at least 128 bits of nonce for script execution cache"); | ||||
Show All 22 Lines |