From 7074cb4e9e91c572d1b5d4f06b0bd0879c7db328 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Thu, 16 May 2024 17:48:56 +0800 Subject: [PATCH] core: make txpool free space calculation more accurate (#22933) --- core/tx_pool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 7a3aa8cd1efe2..813c9a1a86f63 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -711,7 +711,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e return pool.promoteSpecialTx(from, tx, isLocal) } // If the transaction pool is full, discard underpriced transactions - if uint64(pool.all.Count()) >= pool.config.GlobalSlots+pool.config.GlobalQueue { + if uint64(pool.all.Slots()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue { log.Debug("Add transaction to pool full", "hash", hash, "nonce", tx.Nonce()) // If the new transaction is underpriced, don't accept it if !isLocal && pool.priced.Underpriced(tx) {