Changeset View
Changeset View
Standalone View
Standalone View
src/script/sigcache.cpp
Show All 19 Lines | |||||
* Valid signature cache, to avoid doing expensive ECDSA signature checking | * Valid signature cache, to avoid doing expensive ECDSA signature checking | ||||
* twice for every transaction (once when accepted into memory pool, and | * twice for every transaction (once when accepted into memory pool, and | ||||
* again when accepted into the block chain) | * again when accepted into the block chain) | ||||
*/ | */ | ||||
class CSignatureCache { | class CSignatureCache { | ||||
private: | private: | ||||
//! Entries are SHA256(nonce || signature hash || public key || signature): | //! Entries are SHA256(nonce || signature hash || public key || signature): | ||||
uint256 nonce; | uint256 nonce; | ||||
typedef CuckooCache::cache<uint256, SignatureCacheHasher> map_type; | typedef CuckooCache::cache<CuckooCache::KeyOnly<uint256>, | ||||
SignatureCacheHasher> | |||||
map_type; | |||||
map_type setValid; | map_type setValid; | ||||
boost::shared_mutex cs_sigcache; | boost::shared_mutex cs_sigcache; | ||||
public: | public: | ||||
CSignatureCache() { GetRandBytes(nonce.begin(), 32); } | CSignatureCache() { GetRandBytes(nonce.begin(), 32); } | ||||
void ComputeEntry(uint256 &entry, const uint256 &hash, | void ComputeEntry(uint256 &entry, const uint256 &hash, | ||||
const std::vector<uint8_t> &vchSig, | const std::vector<uint8_t> &vchSig, | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |