mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 20:21:56 +00:00
rpc/lib/types: RPCResponse.Result is not a pointer
This commit is contained in:
@@ -67,14 +67,14 @@ func (err RPCError) Error() string {
|
||||
}
|
||||
|
||||
type RPCResponse struct {
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
ID string `json:"id"`
|
||||
Result *json.RawMessage `json:"result,omitempty"`
|
||||
Error *RPCError `json:"error,omitempty"`
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
ID string `json:"id"`
|
||||
Result json.RawMessage `json:"result,omitempty"`
|
||||
Error *RPCError `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func NewRPCSuccessResponse(id string, res interface{}) RPCResponse {
|
||||
var raw *json.RawMessage
|
||||
var rawMsg json.RawMessage
|
||||
|
||||
if res != nil {
|
||||
var js []byte
|
||||
@@ -82,11 +82,10 @@ func NewRPCSuccessResponse(id string, res interface{}) RPCResponse {
|
||||
if err != nil {
|
||||
return RPCInternalError(id, errors.Wrap(err, "Error marshalling response"))
|
||||
}
|
||||
rawMsg := json.RawMessage(js)
|
||||
raw = &rawMsg
|
||||
rawMsg = json.RawMessage(js)
|
||||
}
|
||||
|
||||
return RPCResponse{JSONRPC: "2.0", ID: id, Result: raw}
|
||||
return RPCResponse{JSONRPC: "2.0", ID: id, Result: rawMsg}
|
||||
}
|
||||
|
||||
func NewRPCErrorResponse(id string, code int, msg string, data string) RPCResponse {
|
||||
@@ -98,7 +97,7 @@ func NewRPCErrorResponse(id string, code int, msg string, data string) RPCRespon
|
||||
}
|
||||
|
||||
func (resp RPCResponse) String() string {
|
||||
if resp.Error == nil {
|
||||
if resp.Error != nil {
|
||||
return fmt.Sprintf("[%s %v]", resp.ID, resp.Result)
|
||||
} else {
|
||||
return fmt.Sprintf("[%s %s]", resp.ID, resp.Error)
|
||||
|
Reference in New Issue
Block a user