16 #include <boost/thread.hpp> 31 boost::shared_mutex cs_sigcache;
40 ComputeEntry(
uint256& entry,
const uint256 &hash,
const std::vector<unsigned char>& vchSig,
const CPubKey& pubkey)
46 Get(
const uint256& entry,
const bool erase)
48 boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
49 return setValid.contains(entry, erase);
54 boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
55 setValid.insert(entry);
57 uint32_t setup_bytes(
size_t n)
59 return setValid.setup_bytes(n);
69 static CSignatureCache signatureCache;
78 size_t nMaxCacheSize = std::min(std::max((int64_t)0,
gArgs.
GetArg(
"-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
79 size_t nElems = signatureCache.setup_bytes(nMaxCacheSize);
80 LogPrintf(
"Using %zu MiB out of %zu/2 requested for signature cache, able to store %zu elements\n",
81 (nElems*
sizeof(
uint256)) >>20, (nMaxCacheSize*2)>>20, nElems);
87 signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey);
88 if (signatureCache.Get(entry, !store))
93 signatureCache.Set(entry);
CSHA256 & Write(const unsigned char *data, size_t len)
bool VerifySignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
virtual bool VerifySignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
cache implements a cache with properties similar to a cuckoo-set
An encapsulated public key.
void InitSignatureCache()
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
A hasher class for SHA-256.