Skip to content

Commit

Permalink
ethstats: check if received event is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-vk committed Nov 30, 2016
1 parent 86f9e83 commit 56b4461
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,21 @@ func (s *Service) loop() {
glog.V(logger.Warn).Infof("Full stats report failed: %v", err)
}
case head := <-headSub.Chan():
if head == nil { // node stopped
conn.Close()
return
}
if err = s.reportBlock(out, head.Data.(core.ChainHeadEvent).Block); err != nil {
glog.V(logger.Warn).Infof("Block stats report failed: %v", err)
}
if err = s.reportPending(out); err != nil {
glog.V(logger.Warn).Infof("Post-block transaction stats report failed: %v", err)
}
case <-txSub.Chan():
case ev := <-txSub.Chan():
if ev == nil { // node stopped
conn.Close()
return
}
// Exhaust events to avoid reporting too frequently
for exhausted := false; !exhausted; {
select {
Expand Down

0 comments on commit 56b4461

Please sign in to comment.