Skip to content

Commit f2b434b

Browse files
committed
core/txpool/legacypool: fix tx removal
promoteExecutable already removes the txs from the queue. We just need to remove them from the lookup. Signed-off-by: Csaba Kiraly <[email protected]>
1 parent 39ce64b commit f2b434b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,8 +1413,18 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T
14131413

14141414
// remove all removable transactions
14151415
for _, hash := range removeable {
1416-
pool.removeTx(hash, true, true)
1416+
pool.all.Remove(hash)
1417+
}
1418+
1419+
// release all accounts that have no more transactions in the pool
1420+
for _, addr := range accounts {
1421+
_, hasPending := pool.pending[addr]
1422+
_, hasQueued := pool.queue.get(addr)
1423+
if !hasPending && !hasQueued {
1424+
pool.reserver.Release(addr)
1425+
}
14171426
}
1427+
14181428
return promoted
14191429
}
14201430

core/txpool/legacypool/queue.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ func (q *queue) add(hash common.Hash, tx *types.Transaction) (*common.Hash, erro
145145
return &h, nil
146146
}
147147

148+
// promoteExecutables iterates over all accounts with queued transactions, selecting
149+
// for promotion any that are now executable. It also drops any transactions that are
150+
// deemed too old (nonce too low) or too costly (insufficient funds or over gas limit).
151+
//
152+
// Returns two lists: all transactions that were removed from the queue and selected
153+
// for promotion; all other transactions that were removed from the queue and dropped.
148154
func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash) {
149155
// Track the promoteable transactions to broadcast them at once
150156
var promoteable []*types.Transaction

0 commit comments

Comments
 (0)