core: don't uselessly recheck transactions on dump

This commit is contained in:
Péter Szilágyi 2017-05-31 21:29:50 +03:00
parent 067dc2cbf5
commit 9702badd83
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
1 changed files with 8 additions and 19 deletions

View File

@ -339,17 +339,6 @@ func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) {
pool.mu.Lock() pool.mu.Lock()
defer pool.mu.Unlock() 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) pending := make(map[common.Address]types.Transactions)
for addr, list := range pool.pending { for addr, list := range pool.pending {
pending[addr] = list.Flatten() pending[addr] = list.Flatten()
@ -551,12 +540,12 @@ func (pool *TxPool) Add(tx *types.Transaction) error {
if err != nil { if err != nil {
return err return err
} }
// If we added a new transaction, run promotion checks and return
if !replace {
state, err := pool.currentState() state, err := pool.currentState()
if err != nil { if err != nil {
return err return err
} }
// If we added a new transaction, run promotion checks and return
if !replace {
pool.promoteExecutables(state) pool.promoteExecutables(state)
} }
return nil return nil
@ -579,11 +568,11 @@ func (pool *TxPool) AddBatch(txs []*types.Transaction) error {
} }
// Only reprocess the internal state if something was actually added // Only reprocess the internal state if something was actually added
if added > 0 { if added > 0 {
if !replaced {
state, err := pool.currentState() state, err := pool.currentState()
if err != nil { if err != nil {
return err return err
} }
if !replaced {
pool.promoteExecutables(state) pool.promoteExecutables(state)
} }
} }