From b48cf2cef4b1d1b616f8fea4773139b01f298d04 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 27 Jan 2022 17:19:09 -0500 Subject: [PATCH] mempool: return duplicate tx errors more consistently (backport #7714) (#7718) --- internal/mempool/v1/mempool.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/internal/mempool/v1/mempool.go b/internal/mempool/v1/mempool.go index d78d9d287..82107cb22 100644 --- a/internal/mempool/v1/mempool.go +++ b/internal/mempool/v1/mempool.go @@ -260,19 +260,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 } if ctx == nil {