|
@ -159,7 +159,7 @@ type ( |
|
|
//TODO: this function is not currently used, but some of it's code
|
|
|
//TODO: this function is not currently used, but some of it's code
|
|
|
// needs to be implemented elsewhere
|
|
|
// needs to be implemented elsewhere
|
|
|
func GetSaplingInfo() (int, int, string, string, int, int, int, error) { |
|
|
func GetSaplingInfo() (int, int, string, string, int, int, int, error) { |
|
|
result, rpcErr := RawRequest("getblockchaininfo", []json.RawMessage{}) |
|
|
result, rpcErr := CallRpcWithRetries("getblockchaininfo", []json.RawMessage{}) |
|
|
|
|
|
|
|
|
var err error |
|
|
var err error |
|
|
var errCode int64 |
|
|
var errCode int64 |
|
@ -199,8 +199,8 @@ func GetSaplingInfo() (int, int, string, string, int, int, int, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetLightdInfo() (*walletrpc.LightdInfo, error) { |
|
|
func GetLightdInfo() (*walletrpc.LightdInfo, error) { |
|
|
// result, rpcErr := RawRequest("getinfo", []json.RawMessage{})
|
|
|
params := []json.RawMessage{} |
|
|
result, rpcErr := CallRpcWithRetries("getinfo") |
|
|
result, rpcErr := CallRpcWithRetries("getinfo", params) |
|
|
if rpcErr != nil { |
|
|
if rpcErr != nil { |
|
|
return nil, rpcErr |
|
|
return nil, rpcErr |
|
|
} |
|
|
} |
|
@ -210,8 +210,8 @@ func GetLightdInfo() (*walletrpc.LightdInfo, error) { |
|
|
return nil, rpcErr |
|
|
return nil, rpcErr |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// result, rpcErr = RawRequest("getblockchaininfo", []json.RawMessage{})
|
|
|
params = []json.RawMessage{} |
|
|
result, rpcErr = CallRpcWithRetries("getblockchaininfo") |
|
|
result, rpcErr = CallRpcWithRetries("getblockchaininfo", params) |
|
|
if rpcErr != nil { |
|
|
if rpcErr != nil { |
|
|
return nil, rpcErr |
|
|
return nil, rpcErr |
|
|
} |
|
|
} |
|
@ -275,11 +275,12 @@ func FirstRPC() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func CallRpcWithRetries(method string) (json.RawMessage, error) { |
|
|
func CallRpcWithRetries(method string, params []json.RawMessage) (json.RawMessage, error) { |
|
|
retryCount := 0 |
|
|
retryCount := 0 |
|
|
maxRetries := 50 |
|
|
maxRetries := 50 |
|
|
for { |
|
|
for { |
|
|
result, err := RawRequest(method, []json.RawMessage{}) |
|
|
// params := []json.RawMessage{}
|
|
|
|
|
|
result, err := RawRequest(method, params) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
if retryCount > 0 { |
|
|
if retryCount > 0 { |
|
|
Log.Warn(fmt.Sprintf("%s RPC successful"), method) |
|
|
Log.Warn(fmt.Sprintf("%s RPC successful"), method) |
|
@ -317,8 +318,8 @@ func GetBlockChainInfo() (*HushdRpcReplyGetblockchaininfo, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetCoinsupply() (string, string, int, int, int, int, error) { |
|
|
func GetCoinsupply() (string, string, int, int, int, int, error) { |
|
|
//result1, rpcErr := RawRequest("coinsupply", []json.RawMessage{})
|
|
|
params := []json.RawMessage{} |
|
|
result1, rpcErr := CallRpcWithRetries("coinsupply") |
|
|
result1, rpcErr := CallRpcWithRetries("coinsupply", params) |
|
|
|
|
|
|
|
|
var err error |
|
|
var err error |
|
|
var errCode int64 |
|
|
var errCode int64 |
|
@ -372,7 +373,7 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) { |
|
|
// by height in case a reorg occurs between the two getblock calls;
|
|
|
// by height in case a reorg occurs between the two getblock calls;
|
|
|
// using block hash ensures that we're fetching the same block.
|
|
|
// using block hash ensures that we're fetching the same block.
|
|
|
params[1] = json.RawMessage("1") |
|
|
params[1] = json.RawMessage("1") |
|
|
result, rpcErr := RawRequest("getblock", params) |
|
|
result, rpcErr := CallRpcWithRetries("getblock", params) |
|
|
if rpcErr != nil { |
|
|
if rpcErr != nil { |
|
|
// Check to see if we are requesting a height the hushd doesn't have yet
|
|
|
// Check to see if we are requesting a height the hushd doesn't have yet
|
|
|
if (strings.Split(rpcErr.Error(), ":"))[0] == "-8" { |
|
|
if (strings.Split(rpcErr.Error(), ":"))[0] == "-8" { |
|
@ -391,7 +392,7 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) { |
|
|
} |
|
|
} |
|
|
params[0] = blockHash |
|
|
params[0] = blockHash |
|
|
params[1] = json.RawMessage("0") // non-verbose (raw hex)
|
|
|
params[1] = json.RawMessage("0") // non-verbose (raw hex)
|
|
|
result, rpcErr = RawRequest("getblock", params) |
|
|
result, rpcErr = CallRpcWithRetries("getblock", params) |
|
|
|
|
|
|
|
|
// For some reason, the error responses are not JSON
|
|
|
// For some reason, the error responses are not JSON
|
|
|
if rpcErr != nil { |
|
|
if rpcErr != nil { |
|
@ -464,8 +465,8 @@ func BlockIngestor(c *BlockCache, rep int) { |
|
|
default: |
|
|
default: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// result, err := RawRequest("getbestblockhash", []json.RawMessage{})
|
|
|
params := []json.RawMessage{} |
|
|
result, err := CallRpcWithRetries("getbestblockhash") |
|
|
result, err := CallRpcWithRetries("getbestblockhash", params) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
Log.WithFields(logrus.Fields{ |
|
|
Log.WithFields(logrus.Fields{ |
|
|
"error": err, |
|
|
"error": err, |
|
|