aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/api/eth.go4
-rw-r--r--rpc/xeth.go18
2 files changed, 15 insertions, 7 deletions
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index 820ea761b..5199bd966 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -577,10 +577,10 @@ func (self *ethApi) SubmitWork(req *shared.Request) (interface{}, error) {
func (self *ethApi) SubmitHashrate(req *shared.Request) (interface{}, error) {
args := new(SubmitHashRateArgs)
if err := self.codec.Decode(req.Params, &args); err != nil {
- return nil, shared.NewDecodeParamError(err.Error())
+ return false, shared.NewDecodeParamError(err.Error())
}
self.xeth.RemoteMining().SubmitHashrate(common.HexToHash(args.Id), args.Rate)
- return nil, nil
+ return true, nil
}
func (self *ethApi) Resend(req *shared.Request) (interface{}, error) {
diff --git a/rpc/xeth.go b/rpc/xeth.go
index 65a1edeb8..9527a96c0 100644
--- a/rpc/xeth.go
+++ b/rpc/xeth.go
@@ -53,7 +53,7 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac
Method: method,
Params: data,
}
- // Send the request over and process the response
+ // Send the request over and retrieve the response
if err := self.client.Send(req); err != nil {
return nil, err
}
@@ -61,9 +61,17 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac
if err != nil {
return nil, err
}
- value, ok := res.(map[string]interface{})
- if !ok {
- return nil, fmt.Errorf("Invalid response type: have %v, want %v", reflect.TypeOf(res), reflect.TypeOf(make(map[string]interface{})))
+ // Ensure the response is valid, and extract the results
+ success, isSuccessResponse := res.(*shared.SuccessResponse)
+ failure, isFailureResponse := res.(*shared.ErrorResponse)
+ switch {
+ case isFailureResponse:
+ return nil, fmt.Errorf("Method invocation failed: %v", failure.Error)
+
+ case isSuccessResponse:
+ return success.Result.(map[string]interface{}), nil
+
+ default:
+ return nil, fmt.Errorf("Invalid response type: %v", reflect.TypeOf(res))
}
- return value, nil
}