Пример #1
0
        private static string GetBlkHash(string rpcAddress, string height, int requestTimes = 4)
        {
            requestTimes--;
            var    reqhttp    = new RpcRequestManager(rpcAddress);
            string returnCode = string.Empty;
            var    resp       = reqhttp.PostRequest("get_block_info", "{\"block_height\":\"" + height + "\"}", out returnCode);

            if (returnCode != "OK")
            {
                if (requestTimes >= 0)
                {
                    Thread.Sleep(1000);
                    return(GetBlkHash(rpcAddress, height, requestTimes));
                }
                throw new Exception("Get Block hash failed exception.");
            }
            var jObj = JObject.Parse(resp);

            return(jObj["result"]["result"]["Blockhash"].ToString());
        }
Пример #2
0
        private static string GetBlkHeight(string rpcAddress, int requestTimes = 4)
        {
            requestTimes--;
            var    reqhttp    = new RpcRequestManager(rpcAddress);
            string returnCode = string.Empty;
            var    resp       = reqhttp.PostRequest("get_block_height", "{}", out returnCode);

            Logger.WriteInfo("Query block height status: {0}, return message: {1}", returnCode, resp);
            if (returnCode != "OK")
            {
                if (requestTimes >= 0)
                {
                    Thread.Sleep(1000);
                    return(GetBlkHeight(rpcAddress, requestTimes));
                }
                throw new Exception("Get Block height failed exception.");
            }
            var jObj = JObject.Parse(resp);

            return(jObj["result"]["result"]["block_height"].ToString());
        }