Browse Source

mempool: return duplicate tx errors more consistently (#7714)

pull/7715/head
Sam Kleinman 2 years ago
committed by GitHub
parent
commit
6822378334
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 12 deletions
  1. +5
    -12
      internal/mempool/mempool.go

+ 5
- 12
internal/mempool/mempool.go View File

@ -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})


Loading…
Cancel
Save