mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
#295 Allow RPC ID to be string
This commit is contained in:
parent
cfddb7f3cd
commit
d613bf69bf
@ -102,7 +102,7 @@ func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
|
||||
if reserr != nil {
|
||||
rpchttplogger.Warnln(reserr)
|
||||
jsonerr := &rpc.RpcErrorObject{-32603, reserr.Error()}
|
||||
JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: &reqParsed.ID, Error: jsonerr})
|
||||
JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -34,20 +34,20 @@ const (
|
||||
)
|
||||
|
||||
type RpcRequest struct {
|
||||
ID interface{} `json:"id"`
|
||||
JsonRpc string `json:"jsonrpc"`
|
||||
ID int `json:"id"`
|
||||
Method string `json:"method"`
|
||||
Params []json.RawMessage `json:"params"`
|
||||
}
|
||||
|
||||
type RpcSuccessResponse struct {
|
||||
ID int `json:"id"`
|
||||
ID interface{} `json:"id"`
|
||||
JsonRpc string `json:"jsonrpc"`
|
||||
Result interface{} `json:"result"`
|
||||
}
|
||||
|
||||
type RpcErrorResponse struct {
|
||||
ID *int `json:"id"`
|
||||
ID interface{} `json:"id"`
|
||||
JsonRpc string `json:"jsonrpc"`
|
||||
Error *RpcErrorObject `json:"error"`
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
|
||||
|
||||
// Convert JSON to native types
|
||||
d := json.NewDecoder(req.Body)
|
||||
// d.UseNumber()
|
||||
defer req.Body.Close()
|
||||
err := d.Decode(&reqParsed)
|
||||
|
||||
@ -55,6 +54,7 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
|
||||
rpclogger.Errorln("Error decoding JSON: ", err)
|
||||
return reqParsed, err
|
||||
}
|
||||
|
||||
rpclogger.DebugDetailf("Parsed request: %s", reqParsed)
|
||||
|
||||
return reqParsed, nil
|
||||
|
@ -109,7 +109,7 @@ func sockHandler(api *rpc.EthereumApi) websocket.Handler {
|
||||
if reserr != nil {
|
||||
wslogger.Warnln(reserr)
|
||||
jsonerr := &rpc.RpcErrorObject{-32603, reserr.Error()}
|
||||
JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: &reqParsed.ID, Error: jsonerr})
|
||||
JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: jsonrpcver, ID: reqParsed.ID, Error: jsonerr})
|
||||
continue
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user