示例#1
0
        private void getBlockFromRpc()
        {
            var getcounturl = Helper.url + "?jsonrpc=2.0&id=1&method=getblock&params=[" + Helper.blockHeight + ",1]";

            while (true)
            {
                try
                {
                    var info   = wc.DownloadString(getcounturl);
                    var json   = JObject.Parse(info);
                    var result = json["result"];

                    var path = "block" + Path.DirectorySeparatorChar + Helper.blockHeight.ToString("D08") + ".txt";
                    SaveBlock.getInstance().Save(result as JObject, path);
                    break;
                }
                catch (Exception e)
                {
                    continue;
                }
            }
            // var info = wc.DownloadString(getcounturl);
            // var json = JObject.Parse(info);
            // var result = json["result"];

            // var path = "block" + Path.DirectorySeparatorChar + Helper.blockHeight.ToString("D08") + ".txt";
            // SaveBlock.getInstance().Save(result as JObject, path);
        }
示例#2
0
        private void getBlockFromRpc()
        {
            JToken result = null;

            try
            {
                var getcounturl = Helper.url + "?jsonrpc=2.0&id=1&method=getblock&params=[" + Helper.blockHeight + ",1]";
                var info        = wc.DownloadString(getcounturl);
                var json        = JObject.Parse(info);
                result = json["result"];
            }
            catch (Exception e)
            {
                Helper.blockHeight--;
            }
            if (result != null)
            {
                Helper.blockHeightMax = int.Parse(result["confirmations"].ToString()) + Helper.blockHeight;
                SaveBlock.getInstance().Save(result as JObject, null);
            }
        }