Return consensusBranchId

This commit is contained in:
Aditya Kulkarni
2019-09-25 17:46:05 -07:00
parent 6f56b8b8e9
commit fbb75e8f20
5 changed files with 62 additions and 48 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, string, error) {
result, rpcErr := rpcClient.RawRequest("getblockchaininfo", make([]json.RawMessage, 0))
var err error
@@ -25,15 +25,15 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
errCode, err = strconv.ParseInt(errParts[0], 10, 32)
//Check to see if we are requesting a height the zcashd doesn't have yet
if err == nil && errCode == -8 {
return -1, "", nil
return -1, "", "", nil
}
return -1, "", errors.Wrap(rpcErr, "error requesting block")
return -1, "", "", errors.Wrap(rpcErr, "error requesting block")
}
var f interface{}
err = json.Unmarshal(result, &f)
if err != nil {
return -1, "", errors.Wrap(err, "error reading JSON response")
return -1, "", "", errors.Wrap(err, "error reading JSON response")
}
chainName := f.(map[string]interface{})["chain"].(string)
@@ -42,7 +42,10 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
saplingJSON := upgradeJSON.(map[string]interface{})["76b809bb"] // Sapling ID
saplingHeight := saplingJSON.(map[string]interface{})["activationheight"].(float64)
return int(saplingHeight), chainName, nil
consensus := f.(map[string]interface{})["consensus"]
branchID := consensus.(map[string]interface{})["nextblock"].(string)
return int(saplingHeight), chainName, branchID, nil
}
func getBlockFromRPC(rpcClient *rpcclient.Client, height int) (*walletrpc.CompactBlock, error) {