mirror of https://github.com/status-im/op-geth.git
rpc: golint error with context as last parameter (#16657)
* rpc/*: golint error with context as last parameter * Update json.go
This commit is contained in:
parent
541f299fbb
commit
2ad511ce09
|
@ -191,7 +191,7 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
defer codec.Close()
|
defer codec.Close()
|
||||||
|
|
||||||
w.Header().Set("content-type", contentType)
|
w.Header().Set("content-type", contentType)
|
||||||
srv.ServeSingleRequest(codec, OptionMethodInvocation, ctx)
|
srv.ServeSingleRequest(ctx, codec, OptionMethodInvocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateRequest returns a non-zero response code and error message if the
|
// validateRequest returns a non-zero response code and error message if the
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewInProcClient attaches an in-process connection to the given RPC server.
|
// DialInProc attaches an in-process connection to the given RPC server.
|
||||||
func DialInProc(handler *Server) *Client {
|
func DialInProc(handler *Server) *Client {
|
||||||
initctx := context.Background()
|
initctx := context.Background()
|
||||||
c, _ := newClient(initctx, func(context.Context) (net.Conn, error) {
|
c, _ := newClient(initctx, func(context.Context) (net.Conn, error) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {
|
||||||
// If singleShot is true it will process a single request, otherwise it will handle
|
// If singleShot is true it will process a single request, otherwise it will handle
|
||||||
// requests until the codec returns an error when reading a request (in most cases
|
// requests until the codec returns an error when reading a request (in most cases
|
||||||
// an EOF). It executes requests in parallel when singleShot is false.
|
// an EOF). It executes requests in parallel when singleShot is false.
|
||||||
func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecOption, ctx context.Context) error {
|
func (s *Server) serveRequest(ctx context.Context, codec ServerCodec, singleShot bool, options CodecOption) error {
|
||||||
var pend sync.WaitGroup
|
var pend sync.WaitGroup
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -216,14 +216,14 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO
|
||||||
// stopped. In either case the codec is closed.
|
// stopped. In either case the codec is closed.
|
||||||
func (s *Server) ServeCodec(codec ServerCodec, options CodecOption) {
|
func (s *Server) ServeCodec(codec ServerCodec, options CodecOption) {
|
||||||
defer codec.Close()
|
defer codec.Close()
|
||||||
s.serveRequest(codec, false, options, context.Background())
|
s.serveRequest(context.Background(), codec, false, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeSingleRequest reads and processes a single RPC request from the given codec. It will not
|
// ServeSingleRequest reads and processes a single RPC request from the given codec. It will not
|
||||||
// close the codec unless a non-recoverable error has occurred. Note, this method will return after
|
// close the codec unless a non-recoverable error has occurred. Note, this method will return after
|
||||||
// a single request has been processed!
|
// a single request has been processed!
|
||||||
func (s *Server) ServeSingleRequest(codec ServerCodec, options CodecOption, ctx context.Context) {
|
func (s *Server) ServeSingleRequest(ctx context.Context, codec ServerCodec, options CodecOption) {
|
||||||
s.serveRequest(codec, true, options, ctx)
|
s.serveRequest(ctx, codec, true, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish,
|
// Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish,
|
||||||
|
|
Loading…
Reference in New Issue