Skip to content

Commit

Permalink
core: collect NewTxsEvent items without holding reorg lock (ethereum#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng762 authored and gzliudan committed May 13, 2024
1 parent 6243714 commit cf41742
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,7 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
}
// Check for pending transactions for every account that sent new ones
promoted := pool.promoteExecutables(promoteAddrs)
for _, tx := range promoted {
addr, _ := types.Sender(pool.signer, tx)
if _, ok := events[addr]; !ok {
events[addr] = newTxSortedMap()
}
events[addr].Put(tx)
}

// If a new block appeared, validate the pool of pending transactions. This will
// remove any transaction that has been included in the block or was invalidated
// because of another transaction (e.g. higher gas price).
Expand All @@ -1213,6 +1207,13 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
pool.mu.Unlock()

// Notify subsystems for newly added transactions
for _, tx := range promoted {
addr, _ := types.Sender(pool.signer, tx)
if _, ok := events[addr]; !ok {
events[addr] = newTxSortedMap()
}
events[addr].Put(tx)
}
if len(events) > 0 {
var txs []*types.Transaction
for _, set := range events {
Expand Down

0 comments on commit cf41742

Please sign in to comment.