From b750ef94a7f00756fd4fa2afe9a532caa4cf76e0 Mon Sep 17 00:00:00 2001 From: bitsofproof Date: Tue, 13 Nov 2012 08:18:40 +0100 Subject: [PATCH] lower granularity of locks in signature cache --- src/com/bitsofproof/supernode/core/Script.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/bitsofproof/supernode/core/Script.java b/src/com/bitsofproof/supernode/core/Script.java index fbc901f8..5e662dce 100644 --- a/src/com/bitsofproof/supernode/core/Script.java +++ b/src/com/bitsofproof/supernode/core/Script.java @@ -1568,7 +1568,19 @@ else if ( (hashType & 0x1f) == SIGHASH_SINGLE ) String cacheKey = c.toString (); synchronized ( validSignatureCache ) { - return validSignatureCache.contains (cacheKey) || ECKeyPair.verify (hash, sig, pubkey) && validSignatureCache.add (cacheKey); + if ( validSignatureCache.contains (cacheKey) ) + { + return true; + } + } + if ( ECKeyPair.verify (hash, sig, pubkey) ) + { + synchronized ( validSignatureCache ) + { + validSignatureCache.add (cacheKey); + } + return true; } + return false; } }