Skip to content

Commit

Permalink
ethstats: avoid blocking chan when received invalid stats request (#2…
Browse files Browse the repository at this point in the history
…1073)

* ethstats: avoid blocking chan when received invalid stats request

* ethstats: minor code polishes

Co-authored-by: Péter Szilágyi <[email protected]>
  • Loading branch information
duanhao0814 and karalabe authored May 26, 2020
1 parent 7ddb402 commit 81e9cae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,11 @@ func (s *Service) readLoop(conn *websocket.Conn) {
request, ok := msg["emit"][1].(map[string]interface{})
if !ok {
log.Warn("Invalid stats history request", "msg", msg["emit"][1])
s.histCh <- nil
continue // Ethstats sometime sends invalid history requests, ignore those
select {
case s.histCh <- nil: // Treat it as an no indexes request
default:
}
continue
}
list, ok := request["list"].([]interface{})
if !ok {
Expand Down Expand Up @@ -349,7 +352,7 @@ func (s *Service) readLoop(conn *websocket.Conn) {
}
}

// nodeInfo is the collection of metainformation about a node that is displayed
// nodeInfo is the collection of meta information about a node that is displayed
// on the monitoring page.
type nodeInfo struct {
Name string `json:"name"`
Expand Down

0 comments on commit 81e9cae

Please sign in to comment.