Bitcoin ABC 0.30.7
P2P Digital Currency
sigcache.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_SCRIPT_SIGCACHE_H
7#define BITCOIN_SCRIPT_SIGCACHE_H
8
10#include <util/hasher.h>
11
12#include <optional>
13#include <vector>
14
15// DoS prevention: limit cache size to 32MiB (over 1000000 entries on 64-bit
16// systems). Due to how we count cache size, actual memory usage is slightly
17// more (~32.25 MiB)
18static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES{32 << 20};
19
20class CPubKey;
21
23private:
24 bool store;
25
26 bool IsCached(const std::vector<uint8_t> &vchSig, const CPubKey &vchPubKey,
27 const uint256 &sighash) const;
28
29public:
31 unsigned int nInIn,
32 const Amount amountIn, bool storeIn,
34 : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn),
35 store(storeIn) {}
36
37 bool VerifySignature(const std::vector<uint8_t> &vchSig,
38 const CPubKey &vchPubKey,
39 const uint256 &sighash) const override;
40
42};
43
44[[nodiscard]] bool InitSignatureCache(size_t max_size_bytes);
45
46#endif // BITCOIN_SCRIPT_SIGCACHE_H
An encapsulated public key.
Definition: pubkey.h:31
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:192
friend class TestCachingTransactionSignatureChecker
Definition: sigcache.h:41
bool VerifySignature(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
Definition: sigcache.cpp:122
bool IsCached(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
Definition: sigcache.cpp:115
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const Amount amountIn, bool storeIn, PrecomputedTransactionData &txdataIn)
Definition: sigcache.h:30
256-bit opaque blob.
Definition: uint256.h:129
static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES
Definition: sigcache.h:18
bool InitSignatureCache(size_t max_size_bytes)
Definition: sigcache.cpp:85
Definition: amount.h:19
Precompute sighash midstate to avoid quadratic hashing.
Definition: transaction.h:325