Correct ReadResultCmd for getaddednodeinfo.

The returned result was previously a []interface{} instead of a
[]GetAddedNodeInfoResult.  This commit resolves that issue.

ok @jcvernaleo
This commit is contained in:
Dave Collins 2014-04-08 00:01:14 -05:00
parent b0242a8793
commit 7c39a02ed1
2 changed files with 12 additions and 9 deletions

View file

@ -888,15 +888,18 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
// getaddednodeinfo can either return a JSON object or a
// slice of strings depending on the verbose flag. Choose the
// right form accordingly.
var res interface{}
if strings.Contains(string(objmap["result"]), "{") {
res = []GetAddedNodeInfoResult{}
var res []GetAddedNodeInfoResult
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
result.Result = res
}
} else {
res = []string{}
}
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
result.Result = res
var res []string
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
result.Result = res
}
}
case "getinfo":
var res InfoResult

View file

@ -439,7 +439,7 @@ github.com/conformal/btcjson/jsonfxns.go jsonRpcSend 62.50% (10/16)
github.com/conformal/btcjson/jsoncmd.go SignRawTransactionCmd.MarshalJSON 62.50% (5/8)
github.com/conformal/btcjson/jsonapi.go rpcCommand 61.54% (8/13)
github.com/conformal/btcjson/jsoncmd.go GetTxOutCmd.UnmarshalJSON 59.09% (13/22)
github.com/conformal/btcjson/jsonapi.go ReadResultCmd 58.93% (66/112)
github.com/conformal/btcjson/jsonapi.go ReadResultCmd 57.89% (66/114)
github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.MarshalJSON 57.14% (4/7)
github.com/conformal/btcjson/jsonapi.go rpcRawCommand 53.33% (8/15)
github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.UnmarshalJSON 50.00% (12/24)
@ -461,5 +461,5 @@ github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Id 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go RegisterCustomCmd 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go unparsableCmd.SetId 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1)
github.com/conformal/btcjson --------------------------------------- 78.25% (2205/2818)
github.com/conformal/btcjson --------------------------------------- 78.19% (2205/2820)