aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-10-30 23:38:40 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2015-10-31 01:15:11 +0100
commit0b9e9dca4e88e41f7dae4fd9cd8e0f93fabafe01 (patch)
tree1b779dca561d32e9888d77679b8f1c65f61af088 /src/script
parent830e3f3d027ba5c8121eed0f6a9ce99961352572 (diff)
Evict sigcache entries that are seen in a block
Diffstat (limited to 'src/script')
-rw-r--r--src/script/sigcache.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp
index 9dc7f0fcd5..eee96e7c2d 100644
--- a/src/script/sigcache.cpp
+++ b/src/script/sigcache.cpp
@@ -62,6 +62,12 @@ public:
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);
@@ -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;
}