Add support for GetRawMempoolResult.

This commit is contained in:
Dave Collins 2014-02-16 14:02:24 -06:00
parent 6a2b93e622
commit 81843d269f

View file

@ -93,6 +93,17 @@ type GetPeerInfoResult struct {
SyncNode bool `json:"syncnode"`
}
// GetRawMempoolResult models the data returned from the getrawmempool command.
type GetRawMempoolResult struct {
Size int `json:"size"`
Fee float64 `json:"fee"`
Time int64 `json:"time"`
Height int64 `json:"height"`
StartingPriority int `json:"startingpriority"`
CurrentPriority int `json:"currentpriority"`
Depends []string `json:"depends"`
}
// TxRawResult models the data from the getrawtransaction command.
type TxRawResult struct {
Hex string `json:"hex"`
@ -957,6 +968,23 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
if err == nil {
result.Result = res
}
case "getrawmempool":
// getrawmempool can either return a map of JSON objects or
// an array of strings depending on the verbose flag. Choose
// the right form accordingly.
if strings.Contains(string(objmap["result"]), "{") {
var res map[string]GetRawMempoolResult
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
result.Result = res
}
} else {
var res []string
err = json.Unmarshal(objmap["result"], &res)
if err == nil {
result.Result = res
}
}
case "getwork":
// getwork can either return a JSON object or a boolean
// depending on whether or not data was provided. Choose the