Bitcoin ABC  0.26.3
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 
9 #include <script/interpreter.h>
10 #include <util/hasher.h>
11 
12 #include <vector>
13 
14 // DoS prevention: limit cache size to 32MB (over 1000000 entries on 64-bit
15 // systems). Due to how we count cache size, actual memory usage is slightly
16 // more (~32.25 MB)
17 static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE = 32;
18 // Maximum sig cache size allowed
19 static const int64_t MAX_MAX_SIG_CACHE_SIZE = 16384;
20 
21 class CPubKey;
22 
24 private:
25  bool store;
26 
27  bool IsCached(const std::vector<uint8_t> &vchSig, const CPubKey &vchPubKey,
28  const uint256 &sighash) const;
29 
30 public:
32  unsigned int nInIn,
33  const Amount amountIn, bool storeIn,
35  : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn),
36  store(storeIn) {}
37 
38  bool VerifySignature(const std::vector<uint8_t> &vchSig,
39  const CPubKey &vchPubKey,
40  const uint256 &sighash) const override;
41 
43 };
44 
45 void InitSignatureCache();
46 
47 #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:194
friend class TestCachingTransactionSignatureChecker
Definition: sigcache.h:42
bool VerifySignature(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
Definition: sigcache.cpp:117
bool IsCached(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
Definition: sigcache.cpp:110
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const Amount amountIn, bool storeIn, PrecomputedTransactionData &txdataIn)
Definition: sigcache.h:31
256-bit opaque blob.
Definition: uint256.h:127
void InitSignatureCache()
Definition: sigcache.cpp:78
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:17
static const int64_t MAX_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:19
Definition: amount.h:19
Precompute sighash midstate to avoid quadratic hashing.
Definition: transaction.h:331