core, eth, event, miner, xeth: fix event post / subscription race

This commit is contained in:
Péter Szilágyi
2015-10-12 15:04:38 +03:00
parent 315a422ba7
commit 402fd6e8c6
11 changed files with 123 additions and 94 deletions

View File

@ -84,19 +84,16 @@ func (self *GasPriceOracle) processPastBlocks() {
}
func (self *GasPriceOracle) listenLoop() {
for {
ev, isopen := <-self.events.Chan()
if !isopen {
break
}
switch ev := ev.(type) {
defer self.events.Unsubscribe()
for event := range self.events.Chan() {
switch event := event.Data.(type) {
case core.ChainEvent:
self.processBlock(ev.Block)
self.processBlock(event.Block)
case core.ChainSplitEvent:
self.processBlock(ev.Block)
self.processBlock(event.Block)
}
}
self.events.Unsubscribe()
}
func (self *GasPriceOracle) processBlock(block *types.Block) {