diff options
author | Bas van Kervel <basvankervel@gmail.com> | 2016-12-13 17:13:07 +0800 |
---|---|---|
committer | Bas van Kervel <basvankervel@gmail.com> | 2016-12-13 17:38:04 +0800 |
commit | 9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd (patch) | |
tree | 45148ec2b5857a3f6d2db44674ce2f5afbf6f22c /core | |
parent | a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b (diff) | |
download | dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar.gz dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar.bz2 dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar.lz dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar.xz dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.tar.zst dexon-9f1520b4c04b7dc8eec5dccb901bb1cb7da9a7cd.zip |
core: init pending state in tx pool on creation
Diffstat (limited to 'core')
-rw-r--r-- | core/tx_pool.go | 14 |
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) |