diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index c70e169c84..48462063fe 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1400,7 +1400,7 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) { // invalidated transactions (low nonce, low balance) are deleted. func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.Transaction { gasLimit := pool.currentHead.Load().GasLimit - promotable, dropped := pool.queue.promoteExecutables(accounts, gasLimit, pool.currentState, pool.pendingNonces) + promotable, dropped, removedAddresses := pool.queue.promoteExecutables(accounts, gasLimit, pool.currentState, pool.pendingNonces) promoted := make([]*types.Transaction, 0, len(promotable)) // promote all promoteable transactions @@ -1417,7 +1417,7 @@ func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.T } // release all accounts that have no more transactions in the pool - for _, addr := range accounts { + for _, addr := range removedAddresses { _, hasPending := pool.pending[addr] _, hasQueued := pool.queue.get(addr) if !hasPending && !hasQueued { diff --git a/core/txpool/legacypool/queue.go b/core/txpool/legacypool/queue.go index a9e4f0de15..3fcb964bf1 100644 --- a/core/txpool/legacypool/queue.go +++ b/core/txpool/legacypool/queue.go @@ -149,12 +149,14 @@ func (q *queue) add(hash common.Hash, tx *types.Transaction) (*common.Hash, erro // for promotion any that are now executable. It also drops any transactions that are // deemed too old (nonce too low) or too costly (insufficient funds or over gas limit). // -// Returns two lists: all transactions that were removed from the queue and selected -// for promotion; all other transactions that were removed from the queue and dropped. -func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash) { +// Returns three lists: all transactions that were removed from the queue and selected +// for promotion; all other transactions that were removed from the queue and dropped; +// the list of addresses removed. +func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, currentState *state.StateDB, nonces *noncer) ([]*types.Transaction, []common.Hash, []common.Address) { // Track the promotable transactions to broadcast them at once var promotable []*types.Transaction var dropped []common.Hash + var removedAddresses []common.Address // Iterate over all accounts and promote any executable transactions for _, addr := range accounts { @@ -196,9 +198,10 @@ func (q *queue) promoteExecutables(accounts []common.Address, gasLimit uint64, c if list.Empty() { delete(q.queued, addr) delete(q.beats, addr) + removedAddresses = append(removedAddresses, addr) } } - return promotable, dropped + return promotable, dropped, removedAddresses } // truncate drops the oldest transactions from the queue until the total