ethstats: avoid blocking chan when received invalid stats request (#21073)

* ethstats: avoid blocking chan when received invalid stats request

* ethstats: minor code polishes

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
Hao Duan 2020-05-26 18:09:00 +08:00 committed by GitHub
parent 7ddb40239b
commit 81e9caed7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -320,8 +320,11 @@ func (s *Service) readLoop(conn *websocket.Conn) {
request, ok := msg["emit"][1].(map[string]interface{}) request, ok := msg["emit"][1].(map[string]interface{})
if !ok { if !ok {
log.Warn("Invalid stats history request", "msg", msg["emit"][1]) log.Warn("Invalid stats history request", "msg", msg["emit"][1])
s.histCh <- nil select {
continue // Ethstats sometime sends invalid history requests, ignore those case s.histCh <- nil: // Treat it as an no indexes request
default:
}
continue
} }
list, ok := request["list"].([]interface{}) list, ok := request["list"].([]interface{})
if !ok { if !ok {