Skip to content

Commit 0b9e9dc

Browse files
committed
Evict sigcache entries that are seen in a block
1 parent 830e3f3 commit 0b9e9dc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/script/sigcache.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class CSignatureCache
6262
return setValid.count(entry);
6363
}
6464

65+
void Erase(const uint256& entry)
66+
{
67+
boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
68+
setValid.erase(entry);
69+
}
70+
6571
void Set(const uint256& entry)
6672
{
6773
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
9096
uint256 entry;
9197
signatureCache.ComputeEntry(entry, sighash, vchSig, pubkey);
9298

93-
if (signatureCache.Get(entry))
99+
if (signatureCache.Get(entry)) {
100+
if (!store) {
101+
signatureCache.Erase(entry);
102+
}
94103
return true;
104+
}
95105

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

99-
if (store)
109+
if (store) {
100110
signatureCache.Set(entry);
111+
}
101112
return true;
102113
}

0 commit comments

Comments
 (0)