diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-10 19:59:45 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-10 23:13:32 +0800 |
commit | 4407524d13994759230ce6d31d828914597e8f6c (patch) | |
tree | c746236deea60c34d40c0238a4551a2eafd9b8ae | |
parent | 29f7902fee0750c571adad06bd614365ad86e8f5 (diff) | |
download | go-tangerine-4407524d13994759230ce6d31d828914597e8f6c.tar.gz go-tangerine-4407524d13994759230ce6d31d828914597e8f6c.tar.zst go-tangerine-4407524d13994759230ce6d31d828914597e8f6c.zip |
core: fixed race condition for subscriptions
-rw-r--r-- | core/transaction_pool.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go index b63a4dcab..4a0594228 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -58,6 +58,7 @@ func NewTxPool(eventMux *event.TypeMux, currentStateFn stateFn, gasLimitFn func( currentState: currentStateFn, gasLimit: gasLimitFn, pendingState: state.ManageState(currentStateFn()), + events: eventMux.Subscribe(ChainEvent{}), } go pool.eventLoop() @@ -68,7 +69,6 @@ func (pool *TxPool) eventLoop() { // Track chain events. When a chain events occurs (new chain canon block) // we need to know the new state. The new state will help us determine // the nonces in the managed state - pool.events = pool.eventMux.Subscribe(ChainEvent{}) for _ = range pool.events.Chan() { pool.mu.Lock() @@ -103,7 +103,6 @@ func (pool *TxPool) resetState() { } func (pool *TxPool) Stop() { - pool.pending = make(map[common.Hash]*types.Transaction) close(pool.quit) pool.events.Unsubscribe() glog.V(logger.Info).Infoln("TX Pool stopped") |