15 #include <boost/thread.hpp> 30 boost::shared_mutex cs_sigcache;
39 ComputeEntry(
uint256& entry,
const uint256 &hash,
const std::vector<unsigned char>& vchSig,
const CPubKey& pubkey)
45 Get(
const uint256& entry,
const bool erase)
47 boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
48 return setValid.contains(entry, erase);
53 boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
54 setValid.insert(entry);
56 uint32_t setup_bytes(
size_t n)
58 return setValid.setup_bytes(n);
68 static CSignatureCache signatureCache;
77 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);
78 size_t nElems = signatureCache.setup_bytes(nMaxCacheSize);
79 LogPrintf(
"Using %zu MiB out of %zu/2 requested for signature cache, able to store %zu elements\n",
80 (nElems*
sizeof(
uint256)) >>20, (nMaxCacheSize*2)>>20, nElems);
86 signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey);
87 if (signatureCache.Get(entry, !store))
92 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
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
cache implements a cache with properties similar to a cuckoo-set
An encapsulated public key.
void InitSignatureCache()
virtual bool VerifySignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
A hasher class for SHA-256.