Skip to content

Commit 9702bad

Browse files
committed
core: don't uselessly recheck transactions on dump
1 parent 067dc2c commit 9702bad

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

core/tx_pool.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,6 @@ func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) {
339339
pool.mu.Lock()
340340
defer pool.mu.Unlock()
341341

342-
state, err := pool.currentState()
343-
if err != nil {
344-
return nil, err
345-
}
346-
347-
// check queue first
348-
pool.promoteExecutables(state)
349-
350-
// invalidate any txs
351-
pool.demoteUnexecutables(state)
352-
353342
pending := make(map[common.Address]types.Transactions)
354343
for addr, list := range pool.pending {
355344
pending[addr] = list.Flatten()
@@ -551,12 +540,12 @@ func (pool *TxPool) Add(tx *types.Transaction) error {
551540
if err != nil {
552541
return err
553542
}
554-
state, err := pool.currentState()
555-
if err != nil {
556-
return err
557-
}
558543
// If we added a new transaction, run promotion checks and return
559544
if !replace {
545+
state, err := pool.currentState()
546+
if err != nil {
547+
return err
548+
}
560549
pool.promoteExecutables(state)
561550
}
562551
return nil
@@ -579,11 +568,11 @@ func (pool *TxPool) AddBatch(txs []*types.Transaction) error {
579568
}
580569
// Only reprocess the internal state if something was actually added
581570
if added > 0 {
582-
state, err := pool.currentState()
583-
if err != nil {
584-
return err
585-
}
586571
if !replaced {
572+
state, err := pool.currentState()
573+
if err != nil {
574+
return err
575+
}
587576
pool.promoteExecutables(state)
588577
}
589578
}

0 commit comments

Comments
 (0)