p2p/simulations: fix staticcheck warnings (#20322)

This commit is contained in:
Felix Lange
2019-11-19 17:16:42 +01:00
committed by GitHub
parent 9e8cc00b73
commit df206d2513
5 changed files with 128 additions and 190 deletions

View File

@ -384,12 +384,6 @@ func (s *Server) StreamNetworkEvents(w http.ResponseWriter, req *http.Request) {
sub := s.network.events.Subscribe(events)
defer sub.Unsubscribe()
// stop the stream if the client goes away
var clientGone <-chan bool
if cn, ok := w.(http.CloseNotifier); ok {
clientGone = cn.CloseNotify()
}
// write writes the given event and data to the stream like:
//
// event: <event>
@ -455,6 +449,7 @@ func (s *Server) StreamNetworkEvents(w http.ResponseWriter, req *http.Request) {
}
}
clientGone := req.Context().Done()
for {
select {
case event := <-events:
@ -710,7 +705,7 @@ func (s *Server) wrapHandler(handler http.HandlerFunc) httprouter.Handle {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
ctx := context.Background()
ctx := req.Context()
if id := params.ByName("nodeid"); id != "" {
var nodeID enode.ID