func (s *SigCache) Add(sigHash chainhash.Hash, sig *btcec.Signature, pubKey *btcec.PublicKey) {
	s.Lock()
	defer s.Unlock()
	if s.maxEntries <= 0 {
		return
	}
	if uint(len(s.validSigs)+1) > s.maxEntries {
		for sigEntry := range s.validSigs {
			delete(s.validSigs, sigEntry)
			break
		}
	}
	s.validSigs[sigHash] = sigCacheEntry{sig, pubKey}
}
Add adds an entry for a signature over 'sigHash' under public key 'pubKey'
to the signature cache. In the event that the SigCache is 'full', an
existing entry is randomly chosen to be evicted in order to make space for
the new entry.

NOTE: This function is safe for concurrent access. Writers will block
simultaneous readers until function execution has concluded.
package txscript
import (
	"sync"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcd/chaincfg/chainhash"
)
type sigCacheEntry struct {
	sig    *btcec.Signature
	pubKey *btcec.PublicKey
}
type SigCache struct {
	sync.RWMutex
	validSigs  map[chainhash.Hash]sigCacheEntry
	maxEntries uint
}
func NewSigCache(maxEntries uint) *SigCache {
	return &SigCache{
		validSigs:  make(map[chainhash.Hash]sigCacheEntry, maxEntries),
		maxEntries: maxEntries,
	}
}
func (s *SigCache) Exists(sigHash chainhash.Hash, sig *btcec.Signature, pubKey *btcec.PublicKey) bool {
	s.RLock()
	entry, ok := s.validSigs[sigHash]
	s.RUnlock()
	return ok && entry.pubKey.IsEqual(pubKey) && entry.sig.IsEqual(sig)
}