Skip to content

Commit

Permalink
core: don't uselessly recheck transactions on dump
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed May 31, 2017
1 parent 067dc2c commit 9702bad
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,6 @@ func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) {
pool.mu.Lock()
defer pool.mu.Unlock()

state, err := pool.currentState()
if err != nil {
return nil, err
}

// check queue first
pool.promoteExecutables(state)

// invalidate any txs
pool.demoteUnexecutables(state)

pending := make(map[common.Address]types.Transactions)
for addr, list := range pool.pending {
pending[addr] = list.Flatten()
Expand Down Expand Up @@ -551,12 +540,12 @@ func (pool *TxPool) Add(tx *types.Transaction) error {
if err != nil {
return err
}
state, err := pool.currentState()
if err != nil {
return err
}
// If we added a new transaction, run promotion checks and return
if !replace {
state, err := pool.currentState()
if err != nil {
return err
}
pool.promoteExecutables(state)
}
return nil
Expand All @@ -579,11 +568,11 @@ func (pool *TxPool) AddBatch(txs []*types.Transaction) error {
}
// Only reprocess the internal state if something was actually added
if added > 0 {
state, err := pool.currentState()
if err != nil {
return err
}
if !replaced {
state, err := pool.currentState()
if err != nil {
return err
}
pool.promoteExecutables(state)
}
}
Expand Down

0 comments on commit 9702bad

Please sign in to comment.