From 6822378334aa5baaa62a68c082f9538a28727af8 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Thu, 27 Jan 2022 16:44:07 -0500 Subject: [PATCH] mempool: return duplicate tx errors more consistently (#7714) --- internal/mempool/mempool.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index 1850b80d0..bbffcd59d 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -255,19 +255,12 @@ func (txmp *TxMempool) CheckTx( txHash := tx.Key() - // We add the transaction to the mempool's cache and if the transaction already - // exists, i.e. false is returned, then we check if we've seen this transaction - // from the same sender and error if we have. Otherwise, we return nil. + // We add the transaction to the mempool's cache and if the + // transaction is already present in the cache, i.e. false is returned, then we + // check if we've seen this transaction and error if we have. if !txmp.cache.Push(tx) { - wtx, ok := txmp.txStore.GetOrSetPeerByTxHash(txHash, txInfo.SenderID) - if wtx != nil && ok { - // We already have the transaction stored and the we've already seen this - // transaction from txInfo.SenderID. - return types.ErrTxInCache - } - - txmp.logger.Debug("tx exists already in cache", "tx_hash", tx.Hash()) - return nil + txmp.txStore.GetOrSetPeerByTxHash(txHash, txInfo.SenderID) + return types.ErrTxInCache } reqRes, err := txmp.proxyAppConn.CheckTxAsync(ctx, abci.RequestCheckTx{Tx: tx})