add longestchain and notarized to lightinfod

This commit is contained in:
Denio
2019-12-02 11:42:50 +01:00
parent a269cd1e6b
commit 0978322f62
5 changed files with 30 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ import (
"github.com/sirupsen/logrus"
)
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, int, error) {
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, int,int,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, int,
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, "", "",-1, nil
return -1, -1, "", "",-1,-1,-1, nil
}
return -1, -1, "", "",-1, errors.Wrap(rpcErr, "error requesting block")
return -1, -1, "", "",-1,-1,-1, errors.Wrap(rpcErr, "error requesting block")
}
var f interface{}
err = json.Unmarshal(result, &f)
if err != nil {
return -1, -1, "", "",-1, errors.Wrap(err, "error reading JSON response")
return -1, -1, "", "",-1,-1,-1, errors.Wrap(err, "error reading JSON response")
}
chainName := f.(map[string]interface{})["chain"].(string)
@@ -45,12 +45,14 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, int, string, string, int,
saplingHeight := saplingJSON.(map[string]interface{})["activationheight"].(float64)
blockHeight := f.(map[string]interface{})["headers"].(float64)
difficulty := f.(map[string]interface{})["difficulty"].(float64)
difficulty := f.(map[string]interface{})["difficulty"].(float64)
longestchain := f.(map[string]interface{})["longestchain"].(float64)
notarized := f.(map[string]interface{})["notarized"].(float64)
consensus := f.(map[string]interface{})["consensus"]
branchID := consensus.(map[string]interface{})["nextblock"].(string)
return int(saplingHeight), int(blockHeight), chainName, branchID, int(difficulty), nil
return int(saplingHeight), int(blockHeight), chainName, branchID, int(difficulty), int(longestchain), int(notarized), nil
}
func getBlockFromRPC(rpcClient *rpcclient.Client, height int) (*walletrpc.CompactBlock, error) {