aboutsummaryrefslogtreecommitdiffstats
path: root/eth/gasprice.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-10-12 20:04:38 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-10-12 21:22:03 +0800
commit402fd6e8c6a2e379351e0aae10a833fae6bcae6c (patch)
tree30ab93e93af7c70e5df213eb3665f51a293bc4a9 /eth/gasprice.go
parent315a422ba754eae10db21990a809f608f7af62d4 (diff)
downloadgo-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar.gz
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar.bz2
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar.lz
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar.xz
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.tar.zst
go-tangerine-402fd6e8c6a2e379351e0aae10a833fae6bcae6c.zip
core, eth, event, miner, xeth: fix event post / subscription race
Diffstat (limited to 'eth/gasprice.go')
-rw-r--r--eth/gasprice.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/eth/gasprice.go b/eth/gasprice.go
index c08b96129..b4409f346 100644
--- a/eth/gasprice.go
+++ b/eth/gasprice.go
@@ -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) {