Skip to content

Commit

Permalink
Evict sigcache entries that are seen in a block
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Oct 31, 2015
1 parent 830e3f3 commit 0b9e9dc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/script/sigcache.cpp
Expand Up @@ -62,6 +62,12 @@ class CSignatureCache
return setValid.count(entry);
}

void Erase(const uint256& entry)
{
boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
setValid.erase(entry);
}

void Set(const uint256& entry)
{
size_t nMaxCacheSize = GetArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
Expand Down Expand Up @@ -90,13 +96,18 @@ bool CachingTransactionSignatureChecker::VerifySignature(const std::vector<unsig
uint256 entry;
signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey);

if (signatureCache.Get(entry))
if (signatureCache.Get(entry)) {
if (!store) {
signatureCache.Erase(entry);
}
return true;
}

if (!TransactionSignatureChecker::VerifySignature(vchSig, pubkey, sighash))
return false;

if (store)
if (store) {
signatureCache.Set(entry);
}
return true;
}

0 comments on commit 0b9e9dc

Please sign in to comment.