| 1702 | static CSHA256 g_scriptExecutionCacheHasher; |
| 1703 | |
| 1704 | void InitScriptExecutionCache() { |
| 1705 | // Setup the salted hasher |
| 1706 | uint256 nonce = GetRandHash(); |
| 1707 | // We want the nonce to be 64 bytes long to force the hasher to process |
| 1708 | // this chunk, which makes later hash computations more efficient. We |
| 1709 | // just write our 32-byte entropy twice to fill the 64 bytes. |
| 1710 | g_scriptExecutionCacheHasher.Write(nonce.begin(), 32); |
| 1711 | g_scriptExecutionCacheHasher.Write(nonce.begin(), 32); |
| 1712 | // nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero, |
| 1713 | // setup_bytes creates the minimum possible cache (2 elements). |
| 1714 | size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 4), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20); |
| 1715 | size_t nElems = g_scriptExecutionCache.setup_bytes(nMaxCacheSize); |
| 1716 | LogPrintf("Using %zu MiB out of %zu/4 requested for script execution cache, able to store %zu elements\n", |
| 1717 | (nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems); |
| 1718 | } |
| 1719 | |
| 1720 | /** |
| 1721 | * Check whether all of this transaction's input scripts succeed. |