mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
kernel: De-globalize signature cache
Move its ownership to the ChainstateManager class. Next to simplifying usage of the kernel library by no longer requiring manual setup of the cache prior to using validation code, it also slims down the amount of memory allocated by BasicTestingSetup. Use this opportunity to make SignatureCache RAII styled Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -18,12 +18,15 @@
|
||||
|
||||
namespace {
|
||||
const BasicTestingSetup* g_setup;
|
||||
SignatureCache* g_signature_cache;
|
||||
} // namespace
|
||||
|
||||
void initialize_script_sigcache()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<>();
|
||||
static SignatureCache signature_cache{DEFAULT_SIGNATURE_CACHE_BYTES};
|
||||
g_setup = testing_setup.get();
|
||||
g_signature_cache = &signature_cache;
|
||||
}
|
||||
|
||||
FUZZ_TARGET(script_sigcache, .init = initialize_script_sigcache)
|
||||
@@ -36,7 +39,7 @@ FUZZ_TARGET(script_sigcache, .init = initialize_script_sigcache)
|
||||
const CAmount amount = ConsumeMoney(fuzzed_data_provider);
|
||||
const bool store = fuzzed_data_provider.ConsumeBool();
|
||||
PrecomputedTransactionData tx_data;
|
||||
CachingTransactionSignatureChecker caching_transaction_signature_checker{mutable_transaction ? &tx : nullptr, n_in, amount, store, tx_data};
|
||||
CachingTransactionSignatureChecker caching_transaction_signature_checker{mutable_transaction ? &tx : nullptr, n_in, amount, store, *g_signature_cache, tx_data};
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
const auto random_bytes = fuzzed_data_provider.ConsumeBytes<unsigned char>(64);
|
||||
const XOnlyPubKey pub_key(ConsumeUInt256(fuzzed_data_provider));
|
||||
|
||||
Reference in New Issue
Block a user