diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-05 17:33:10 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-05 17:33:10 +0800 |
commit | 212828963172b3921827df15abdc8602480e947d (patch) | |
tree | fdc6b49506651b6a1255f1bcd1dab609ba69a4b6 /rpc | |
parent | 3274db19c7563e31f79418b63f6c10233cbaa32a (diff) | |
parent | 6b939fbeaa7db139e06223926d6b4355ae0e71ca (diff) | |
download | dexon-212828963172b3921827df15abdc8602480e947d.tar dexon-212828963172b3921827df15abdc8602480e947d.tar.gz dexon-212828963172b3921827df15abdc8602480e947d.tar.bz2 dexon-212828963172b3921827df15abdc8602480e947d.tar.lz dexon-212828963172b3921827df15abdc8602480e947d.tar.xz dexon-212828963172b3921827df15abdc8602480e947d.tar.zst dexon-212828963172b3921827df15abdc8602480e947d.zip |
Merge pull request #2171 from karalabe/rpc-modules-fix
rpc: add jsonrpc version to module request, use json types
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/utils.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/rpc/utils.go b/rpc/utils.go index 25321c543..39acf8196 100644 --- a/rpc/utils.go +++ b/rpc/utils.go @@ -218,29 +218,27 @@ func newSubscriptionId() (string, error) { // SupportedModules returns the collection of API's that the RPC server offers // on which the given client connects. func SupportedModules(client Client) (map[string]string, error) { - req := map[string]interface{}{ - "id": 1, - "method": "rpc_modules", + req := JSONRequest{ + Id: new(int64), + Version: "2.0", + Method: "rpc_modules", } - if err := client.Send(req); err != nil { return nil, err } - var response map[string]interface{} + var response JSONSuccessResponse if err := client.Recv(&response); err != nil { return nil, err } - - if payload, ok := response["result"]; ok { + if response.Result != nil { mods := make(map[string]string) - if modules, ok := payload.(map[string]interface{}); ok { + if modules, ok := response.Result.(map[string]interface{}); ok { for m, v := range modules { mods[m] = fmt.Sprintf("%s", v) } return mods, nil } } - return nil, fmt.Errorf("unable to retrieve modules") } |