diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index 241add8f2..438e2a4f5 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -299,8 +299,7 @@ func (txmp *TxMempool) CheckTx( evmNonce: res.EVMNonce, evmAddress: res.EVMSenderAddress, isEVM: res.IsEVM, - expiredCallback: func(removeFromCache bool) { - txmp.metrics.ExpiredTxs.Add(1) + removeHandler: func(removeFromCache bool) { if removeFromCache { txmp.cache.Remove(tx) } @@ -856,7 +855,7 @@ func (txmp *TxMempool) removeTx(wtx *WrappedTx, removeFromCache bool) { atomic.AddInt64(&txmp.sizeBytes, int64(-wtx.Size())) - wtx.expiredCallback(removeFromCache) + wtx.removeHandler(removeFromCache) } // purgeExpiredTxs removes all transactions that have exceeded their respective @@ -905,12 +904,14 @@ func (txmp *TxMempool) purgeExpiredTxs(blockHeight int64) { } for _, wtx := range expiredTxs { + txmp.metrics.ExpiredTxs.Add(1) txmp.removeTx(wtx, !txmp.config.KeepInvalidTxsInCache) } // remove pending txs that have expired txmp.pendingTxs.PurgeExpired(txmp.config.TTLNumBlocks, blockHeight, txmp.config.TTLDuration, now, func(wtx *WrappedTx) { - wtx.expiredCallback(!txmp.config.KeepInvalidTxsInCache) + txmp.metrics.ExpiredTxs.Add(1) + wtx.removeHandler(!txmp.config.KeepInvalidTxsInCache) }) } diff --git a/internal/mempool/tx.go b/internal/mempool/tx.go index 411065db8..025cfda73 100644 --- a/internal/mempool/tx.go +++ b/internal/mempool/tx.go @@ -65,8 +65,8 @@ type WrappedTx struct { // a reCheckTx callback executed. removed bool - // this is the callback that can be called when a transaction expires - expiredCallback func(removeFromCache bool) + // this is the callback that can be called when a transaction is removed + removeHandler func(removeFromCache bool) // evm properties that aid in prioritization evmAddress string