aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/message.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/message.go')
-rw-r--r--rpc/message.go41
1 files changed, 27 insertions, 14 deletions
diff --git a/rpc/message.go b/rpc/message.go
index 0845a2239..78dc6e2ff 100644
--- a/rpc/message.go
+++ b/rpc/message.go
@@ -33,30 +33,29 @@ const (
ErrorDecodeArgs = "Error: Could not decode arguments"
)
-type ErrorResponse struct {
- Error bool `json:"error"`
- ErrorText string `json:"errorText"`
+type RpcRequest struct {
+ JsonRpc string `json:"jsonrpc"`
+ ID int `json:"id"`
+ Method string `json:"method"`
+ Params []json.RawMessage `json:"params"`
}
type RpcSuccessResponse struct {
ID int `json:"id"`
JsonRpc string `json:"jsonrpc"`
- Error bool `json:"error"`
Result interface{} `json:"result"`
}
type RpcErrorResponse struct {
- ID int `json:"id"`
- JsonRpc string `json:"jsonrpc"`
- Error bool `json:"error"`
- ErrorText string `json:"errortext"`
+ ID *int `json:"id"`
+ JsonRpc string `json:"jsonrpc"`
+ Error *RpcErrorObject `json:"error"`
}
-type RpcRequest struct {
- JsonRpc string `json:"jsonrpc"`
- ID int `json:"id"`
- Method string `json:"method"`
- Params []json.RawMessage `json:"params"`
+type RpcErrorObject struct {
+ Code int `json:"code"`
+ Message string `json:"message"`
+ // Data interface{} `json:"data"`
}
func NewErrorResponse(msg string) error {
@@ -206,7 +205,6 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
if len(req.Params) < 1 {
return nil, NewErrorResponse(ErrorArguments)
}
- fmt.Println("FILTER PARAMS", string(req.Params[0]))
args := new(FilterOptions)
r := bytes.NewReader(req.Params[0])
@@ -218,6 +216,21 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
return args, nil
}
+func (req *RpcRequest) ToFilterStringArgs() (string, error) {
+ if len(req.Params) < 1 {
+ return "", NewErrorResponse(ErrorArguments)
+ }
+
+ var args string
+ err := json.Unmarshal(req.Params[0], &args)
+ if err != nil {
+ return "", NewErrorResponse(ErrorDecodeArgs)
+ }
+
+ rpclogger.DebugDetailf("%T %v", args, args)
+ return args, nil
+}
+
func (req *RpcRequest) ToFilterChangedArgs() (int, error) {
if len(req.Params) < 1 {
return 0, NewErrorResponse(ErrorArguments)