RPCResponse.Result is json.RawMessage

This commit is contained in:
Ethan Buchman
2016-01-13 18:37:35 -05:00
parent 0bcae125c2
commit aff561d8c3
5 changed files with 44 additions and 28 deletions

View File

@ -1,7 +1,10 @@
package rpctypes
import (
"encoding/json"
"github.com/tendermint/go-events"
"github.com/tendermint/go-wire"
)
type RPCRequest struct {
@ -39,17 +42,18 @@ type Result interface {
//----------------------------------------
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID string `json:"id"`
Result Result `json:"result"`
Error string `json:"error"`
JSONRPC string `json:"jsonrpc"`
ID string `json:"id"`
Result *json.RawMessage `json:"result"`
Error string `json:"error"`
}
func NewRPCResponse(id string, res Result, err string) RPCResponse {
func NewRPCResponse(id string, res interface{}, err string) RPCResponse {
raw := json.RawMessage(wire.JSONBytes(res))
return RPCResponse{
JSONRPC: "2.0",
ID: id,
Result: res,
Result: &raw,
Error: err,
}
}