MCPcopy Create free account
hub / github.com/ElementsProject/elements / InitScriptExecutionCache

Function InitScriptExecutionCache

src/validation.cpp:1704–1718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1702static CSHA256 g_scriptExecutionCacheHasher;
1703
1704void 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.

Callers 4

AppInitMainFunction · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85
initialize_simplicity_txFunction · 0.85
BasicTestingSetupMethod · 0.85

Calls 5

GetRandHashFunction · 0.85
GetIntArgMethod · 0.80
WriteMethod · 0.45
beginMethod · 0.45
setup_bytesMethod · 0.45

Tested by 3

BOOST_FIXTURE_TEST_CASEFunction · 0.68
initialize_simplicity_txFunction · 0.68
BasicTestingSetupMethod · 0.68