core: make txpool free space calculation more accurate (#22933)

This commit is contained in:
Daniel Liu 2024-05-16 17:48:56 +08:00
parent 684afd0b18
commit d88d2670e5

View file

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