diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-16 01:44:30 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-16 01:44:30 +0800 |
commit | cefe5c80b1cdcab606a169c0be65d9d2ba9bc941 (patch) | |
tree | dbbb116fa71ee396fdeb743a725b14007b43e845 /eth/gasprice.go | |
parent | 2f1f2e4811a6f3094f99b55f6553fe27d83f9aad (diff) | |
parent | 402fd6e8c6a2e379351e0aae10a833fae6bcae6c (diff) | |
download | dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar.gz dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar.bz2 dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar.lz dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar.xz dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.tar.zst dexon-cefe5c80b1cdcab606a169c0be65d9d2ba9bc941.zip |
Merge pull request #1898 from karalabe/eventmux-post-race
core, eth, event, miner, xeth: fix event post / subscription race
Diffstat (limited to 'eth/gasprice.go')
-rw-r--r-- | eth/gasprice.go | 15 |
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) { |