From 44c006b78358402e72c0ec011c16bbdb41e6979e Mon Sep 17 00:00:00 2001
From: Fire Man <55934298+basdevelop@users.noreply.github.com>
Date: Mon, 24 May 2021 20:34:38 +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 5db1d3df329d..0abc092ecb37 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -595,7 +595,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
 		return false, err
 	}
 	// If the transaction pool is full, discard underpriced transactions
-	if uint64(pool.all.Count()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue {
+	if uint64(pool.all.Slots()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue {
 		// If the new transaction is underpriced, don't accept it
 		if !isLocal && pool.priced.Underpriced(tx) {
 			log.Trace("Discarding underpriced transaction", "hash", hash, "price", tx.GasPrice())