From ae572b9038bf1086ad4257c9127afa48d49e113e Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 17 May 2018 11:52:07 +0400 Subject: [PATCH] remove extra call to Exists Refs #345 https://github.com/tendermint/tendermint/issues/1539#issuecomment-387240606 --- mempool/mempool.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index aa2aa4f41..70ef7a38c 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -203,10 +203,9 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) { defer mem.proxyMtx.Unlock() // CACHE - if mem.cache.Exists(tx) { + if !mem.cache.Push(tx) { return ErrTxInCache } - mem.cache.Push(tx) // END CACHE // WAL @@ -463,14 +462,6 @@ func (cache *txCache) Reset() { cache.mtx.Unlock() } -// Exists returns true if the given tx is cached. -func (cache *txCache) Exists(tx types.Tx) bool { - cache.mtx.Lock() - _, exists := cache.map_[string(tx)] - cache.mtx.Unlock() - return exists -} - // Push adds the given tx to the txCache. It returns false if tx is already in the cache. func (cache *txCache) Push(tx types.Tx) bool { cache.mtx.Lock()