mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
remove extra call to Exists
Refs #345 https://github.com/tendermint/tendermint/issues/1539#issuecomment-387240606
This commit is contained in:
@@ -203,10 +203,9 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) {
|
|||||||
defer mem.proxyMtx.Unlock()
|
defer mem.proxyMtx.Unlock()
|
||||||
|
|
||||||
// CACHE
|
// CACHE
|
||||||
if mem.cache.Exists(tx) {
|
if !mem.cache.Push(tx) {
|
||||||
return ErrTxInCache
|
return ErrTxInCache
|
||||||
}
|
}
|
||||||
mem.cache.Push(tx)
|
|
||||||
// END CACHE
|
// END CACHE
|
||||||
|
|
||||||
// WAL
|
// WAL
|
||||||
@@ -463,14 +462,6 @@ func (cache *txCache) Reset() {
|
|||||||
cache.mtx.Unlock()
|
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.
|
// 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 {
|
func (cache *txCache) Push(tx types.Tx) bool {
|
||||||
cache.mtx.Lock()
|
cache.mtx.Lock()
|
||||||
|
Reference in New Issue
Block a user