mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-27 16:32:33 +00:00
Allow getwork result to be a bool or JSON object.
The getwork command alters the output depending on whether or not the optional data parameter was specified. It is a JSON object when no data was provided, and a boolean indicating whether a solution was found when data was provided.
This commit is contained in:
parent
a733633685
commit
5135fd3203
11
jsonapi.go
11
jsonapi.go
@ -933,11 +933,22 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
|
|||||||
result.Result = res
|
result.Result = res
|
||||||
}
|
}
|
||||||
case "getwork":
|
case "getwork":
|
||||||
|
// getwork can either return a JSON object or a boolean
|
||||||
|
// depending on whether or not data was provided. Choose the
|
||||||
|
// right form accordingly.
|
||||||
|
if strings.Contains(string(objmap["result"]), "{") {
|
||||||
var res GetWorkResult
|
var res GetWorkResult
|
||||||
err = json.Unmarshal(objmap["result"], &res)
|
err = json.Unmarshal(objmap["result"], &res)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
result.Result = res
|
result.Result = res
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var res bool
|
||||||
|
err = json.Unmarshal(objmap["result"], &res)
|
||||||
|
if err == nil {
|
||||||
|
result.Result = res
|
||||||
|
}
|
||||||
|
}
|
||||||
case "validateaddress":
|
case "validateaddress":
|
||||||
var res ValidateAddressResult
|
var res ValidateAddressResult
|
||||||
err = json.Unmarshal(objmap["result"], &res)
|
err = json.Unmarshal(objmap["result"], &res)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user