add difficulty to lightdinfo
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, error) {
|
||||
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, int, error) {
|
||||
result, rpcErr := rpcClient.RawRequest("getblockchaininfo", make([]json.RawMessage, 0))
|
||||
|
||||
var err error
|
||||
@@ -27,15 +27,15 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, erro
|
||||
errCode, err = strconv.ParseInt(errParts[0], 10, 32)
|
||||
//Check to see if we are requesting a height the hushd doesn't have yet
|
||||
if err == nil && errCode == -8 {
|
||||
return -1, -1, "", "", nil
|
||||
return -1, -1, "", "",-1, nil
|
||||
}
|
||||
return -1, -1, "", "", errors.Wrap(rpcErr, "error requesting block")
|
||||
return -1, -1, "", "",-1, errors.Wrap(rpcErr, "error requesting block")
|
||||
}
|
||||
|
||||
var f interface{}
|
||||
err = json.Unmarshal(result, &f)
|
||||
if err != nil {
|
||||
return -1, -1, "", "", errors.Wrap(err, "error reading JSON response")
|
||||
return -1, -1, "", "",-1, errors.Wrap(err, "error reading JSON response")
|
||||
}
|
||||
|
||||
chainName := f.(map[string]interface{})["chain"].(string)
|
||||
@@ -45,11 +45,12 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, erro
|
||||
saplingHeight := saplingJSON.(map[string]interface{})["activationheight"].(float64)
|
||||
|
||||
blockHeight := f.(map[string]interface{})["headers"].(float64)
|
||||
difficulty := f.(map[string]interface{})["difficulty"].(float64)
|
||||
|
||||
consensus := f.(map[string]interface{})["consensus"]
|
||||
branchID := consensus.(map[string]interface{})["nextblock"].(string)
|
||||
|
||||
return int(saplingHeight), int(blockHeight), chainName, branchID, nil
|
||||
return int(saplingHeight), int(blockHeight), chainName, branchID, int(difficulty), nil
|
||||
}
|
||||
|
||||
func getBlockFromRPC(rpcClient *rpcclient.Client, height int) (*walletrpc.CompactBlock, error) {
|
||||
|
||||
Reference in New Issue
Block a user