Skip to content

Commit

Permalink
Merge pull request ethereum#3429 from bas-vk/txpool-crash
Browse files Browse the repository at this point in the history
core: init pending state in tx pool on creation
  • Loading branch information
karalabe authored Dec 14, 2016
2 parents fdb8edf + 9f1520b commit 9cc0f60
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func NewTxPool(config *params.ChainConfig, eventMux *event.TypeMux, currentState
quit: make(chan struct{}),
}

pool.resetState()

pool.wg.Add(2)
go pool.eventLoop()
go pool.expirationLoop()
Expand Down Expand Up @@ -196,12 +198,8 @@ func (pool *TxPool) Stop() {
}

func (pool *TxPool) State() *state.ManagedState {
pool.mu.Lock()
defer pool.mu.Unlock()

if pool.pendingState == nil {
pool.resetState()
}
pool.mu.RLock()
defer pool.mu.RUnlock()

return pool.pendingState
}
Expand Down Expand Up @@ -381,10 +379,6 @@ func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction) {
//
// Note, this method assumes the pool lock is held!
func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.Transaction) {
// Init delayed since tx pool could have been started before any state sync
if pool.pendingState == nil {
pool.resetState()
}
// Try to insert the transaction into the pending queue
if pool.pending[addr] == nil {
pool.pending[addr] = newTxList(true)
Expand Down

0 comments on commit 9cc0f60

Please sign in to comment.