aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-12-14 17:17:39 +0800
committerGitHub <noreply@github.com>2016-12-14 17:17:39 +0800
commit9cc0f60666d50e9c186f616c1016eead16d31185 (patch)
tree50db5c399e0e4e9f6d1051adfd106e94eae24993
parentfdb8edf5ea0cc6e8e9b6f3e64c8c4c7f5324eea3 (diff)
parent9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd (diff)
downloadgo-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar.gz
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar.bz2
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar.lz
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar.xz
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.tar.zst
go-tangerine-9cc0f60666d50e9c186f616c1016eead16d31185.zip
Merge pull request #3429 from bas-vk/txpool-crash
core: init pending state in tx pool on creation
-rw-r--r--core/tx_pool.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go
index b805cf226..65e076df9 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -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()
@@ -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
}
@@ -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)