aboutsummaryrefslogtreecommitdiffstats
path: root/ethstats
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@gmail.com>2016-12-01 00:47:39 +0800
committerBas van Kervel <basvankervel@gmail.com>2016-12-01 00:47:39 +0800
commit56b446190aedf7970c9532b1e428fbf1b5b94413 (patch)
tree9b64332963e5c8bfae5c9b3a4f50a1e533e489f2 /ethstats
parent86f9e836bea8161d9f6c1dacaa0b208e86b42e83 (diff)
downloaddexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar.gz
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar.bz2
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar.lz
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar.xz
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.tar.zst
dexon-56b446190aedf7970c9532b1e428fbf1b5b94413.zip
ethstats: check if received event is valid
Diffstat (limited to 'ethstats')
-rw-r--r--ethstats/ethstats.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index b87f5ab78..a5fa84468 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -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 {