Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

sigcache.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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 
11 #include <vector>
12 
13 // DoS prevention: limit cache size to 32MB (over 1000000 entries on 64-bit
14 // systems). Due to how we count cache size, actual memory usage is slightly
15 // more (~32.25 MB)
16 static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE = 32;
17 // Maximum sig cache size allowed
18 static const int64_t MAX_MAX_SIG_CACHE_SIZE = 16384;
19 
20 class CPubKey;
21 
31 {
32 public:
33  template <uint8_t hash_select>
34  uint32_t operator()(const uint256& key) const
35  {
36  static_assert(hash_select <8, "SignatureCacheHasher only has 8 hashes available.");
37  uint32_t u;
38  std::memcpy(&u, key.begin()+4*hash_select, 4);
39  return u;
40  }
41 };
42 
44 {
45 private:
46  bool store;
47 
48 public:
49  CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amount, PrecomputedTransactionData& txdataIn, bool storeIn=true) : TransactionSignatureChecker(txToIn, nInIn, amount, txdataIn), store(storeIn) {}
50 
51  bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const override;
52 };
53 
54 void InitSignatureCache();
55 
56 #endif // BITCOIN_SCRIPT_SIGCACHE_H
bool VerifySignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
Definition: sigcache.cpp:83
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:16
void InitSignatureCache()
Definition: sigcache.cpp:73
unsigned char * begin()
Definition: uint256.h:57
We&#39;re hashing a nonce into the entries themselves, so we don&#39;t need extra blinding in the set hash co...
Definition: sigcache.h:30
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
An encapsulated public key.
Definition: pubkey.h:30
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const CAmount &amount, PrecomputedTransactionData &txdataIn, bool storeIn=true)
Definition: sigcache.h:49
256-bit opaque blob.
Definition: uint256.h:123
static const int64_t MAX_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:18
void * memcpy(void *a, const void *b, size_t c)
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
uint32_t operator()(const uint256 &key) const
Definition: sigcache.h:34
Released under the MIT license