using rpc.CheckTimeouts instead of duplicate timeout check

This commit is contained in:
renaynay 2020-03-30 14:20:29 +02:00
parent aab171f8c6
commit bdd1091b48
No known key found for this signature in database
GPG key ID: 731E44FAAFCD0274
2 changed files with 1 additions and 18 deletions

View file

@ -896,7 +896,6 @@ func retesteth(ctx *cli.Context) error {
} }
handler := node.NewHTTPHandlerStack(srv, cors, vhosts) handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
// start http server // start http server
var RetestethHTTPTimeouts = rpc.HTTPTimeouts{ var RetestethHTTPTimeouts = rpc.HTTPTimeouts{
ReadTimeout: 120 * time.Second, ReadTimeout: 120 * time.Second,

View file

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
"time"
"github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -73,7 +72,7 @@ func (s *Service) Start(server *p2p.Server) error {
// create handler stack and wrap the graphql handler // create handler stack and wrap the graphql handler
handler := node.NewHTTPHandlerStack(s.handler, s.cors, s.vhosts) handler := node.NewHTTPHandlerStack(s.handler, s.cors, s.vhosts)
// make sure timeout values are meaningful // make sure timeout values are meaningful
registerTimeouts(&s.timeouts) rpc.CheckTimeouts(&s.timeouts)
// create http server // create http server
httpSrv := &http.Server{ httpSrv := &http.Server{
Handler: handler, Handler: handler,
@ -86,21 +85,6 @@ func (s *Service) Start(server *p2p.Server) error {
return nil return nil
} }
func registerTimeouts(timeouts *rpc.HTTPTimeouts) {
if timeouts.ReadTimeout < time.Second {
log.Warn("Sanitizing invalid HTTP read timeout", "provided", timeouts.ReadTimeout, "updated", rpc.DefaultHTTPTimeouts.ReadTimeout)
timeouts.ReadTimeout = rpc.DefaultHTTPTimeouts.ReadTimeout
}
if timeouts.WriteTimeout < time.Second {
log.Warn("Sanitizing invalid HTTP write timeout", "provided", timeouts.WriteTimeout, "updated", rpc.DefaultHTTPTimeouts.WriteTimeout)
timeouts.WriteTimeout = rpc.DefaultHTTPTimeouts.WriteTimeout
}
if timeouts.IdleTimeout < time.Second {
log.Warn("Sanitizing invalid HTTP idle timeout", "provided", timeouts.IdleTimeout, "updated", rpc.DefaultHTTPTimeouts.IdleTimeout)
timeouts.IdleTimeout = rpc.DefaultHTTPTimeouts.IdleTimeout
}
}
// newHandler returns a new `http.Handler` that will answer GraphQL queries. // newHandler returns a new `http.Handler` that will answer GraphQL queries.
// It additionally exports an interactive query browser on the / endpoint. // It additionally exports an interactive query browser on the / endpoint.
func newHandler(backend ethapi.Backend) (http.Handler, error) { func newHandler(backend ethapi.Backend) (http.Handler, error) {