core, event: txpool deliver tx in order

This commit is contained in:
Illya Havsiyevych 2017-02-20 12:20:54 +02:00
parent e51f65af1f
commit 01d594629a
2 changed files with 5 additions and 2 deletions

View file

@ -394,7 +394,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
// Set the potentially new pending nonce and notify any subsystems of the new tx // Set the potentially new pending nonce and notify any subsystems of the new tx
pool.beats[addr] = time.Now() pool.beats[addr] = time.Now()
pool.pendingState.SetNonce(addr, tx.Nonce()+1) pool.pendingState.SetNonce(addr, tx.Nonce()+1)
go pool.eventMux.Post(TxPreEvent{tx}) pool.eventMux.Post(TxPreEvent{tx})
} }
// Add queues a single transaction in the pool if it is valid. // Add queues a single transaction in the pool if it is valid.

View file

@ -202,10 +202,13 @@ func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {
} }
// Otherwise deliver the event // Otherwise deliver the event
s.postMu.RLock() s.postMu.RLock()
defer s.postMu.RUnlock() go deliver_goroutine(s, event)
}
func deliver_goroutine(s *TypeMuxSubscription, event *TypeMuxEvent) {
select { select {
case s.postC <- event: case s.postC <- event:
case <-s.closing: case <-s.closing:
} }
s.postMu.RUnlock()
} }