Raven Core  3.0.0
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 // Copyright (c) 2017-2019 The Raven Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef RAVEN_SCRIPT_SIGCACHE_H
8 #define RAVEN_SCRIPT_SIGCACHE_H
9 
10 #include "script/interpreter.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 
32 {
33 public:
34  template <uint8_t hash_select>
35  uint32_t operator()(const uint256& key) const
36  {
37  static_assert(hash_select <8, "SignatureCacheHasher only has 8 hashes available.");
38  uint32_t u;
39  std::memcpy(&u, key.begin()+4*hash_select, 4);
40  return u;
41  }
42 };
43 
45 {
46 private:
47  bool store;
48 
49 public:
50  CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn), store(storeIn) {}
51 
52  bool VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const override;
53 };
54 
55 void InitSignatureCache();
56 
57 #endif // RAVEN_SCRIPT_SIGCACHE_H
void InitSignatureCache()
Definition: sigcache.cpp:74
unsigned char * begin()
Definition: uint256.h:57
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const CAmount &amountIn, bool storeIn, PrecomputedTransactionData &txdataIn)
Definition: sigcache.h:50
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:31
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
An encapsulated public key.
Definition: pubkey.h:40
256-bit opaque blob.
Definition: uint256.h:123
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:270
uint32_t operator()(const uint256 &key) const
Definition: sigcache.h:35