From 9f71f090e675f7f8389cf147620a21be726d18af Mon Sep 17 00:00:00 2001 From: David Hill Date: Tue, 31 Jan 2017 13:44:45 -0500 Subject: [PATCH] txscript: Drop the mutex before doing crypto --- txscript/sigcache.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/txscript/sigcache.go b/txscript/sigcache.go index e968c2a2..d9e4fa6c 100644 --- a/txscript/sigcache.go +++ b/txscript/sigcache.go @@ -57,13 +57,10 @@ func NewSigCache(maxEntries uint) *SigCache { // unless there exists a writer, adding an entry to the SigCache. func (s *SigCache) Exists(sigHash chainhash.Hash, sig *btcec.Signature, pubKey *btcec.PublicKey) bool { s.RLock() - defer s.RUnlock() + entry, ok := s.validSigs[sigHash] + s.RUnlock() - if entry, ok := s.validSigs[sigHash]; ok { - return entry.pubKey.IsEqual(pubKey) && entry.sig.IsEqual(sig) - } - - return false + return ok && entry.pubKey.IsEqual(pubKey) && entry.sig.IsEqual(sig) } // Add adds an entry for a signature over 'sigHash' under public key 'pubKey'