Exemple #1
0
        public static int CountTransactions(int start, int end = -1)
        {
            if (start < 0)
            {
                return(-1);
            }
            if (start == end)
            {
                return(0);
            }
            HttpWebRequest webReq = null;

            webReq = (HttpWebRequest)WebRequest.Create(new Uri(CreateCommand(countTransactionsCommand, new List <string> {
                (start + 1).ToString(), end.ToString()
            })));
            webReq.Method        = "GET";
            webReq.ContentType   = "application/x-www-form-urlencoded";
            webReq.Timeout       = 6000000;
            webReq.ContentLength = 0;

            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            StreamReader    sr       = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            string          ret      = sr.ReadToEnd();

            sr.Close();
            response.Close();
            ReturnedResult deserializedResult = JsonConvert.DeserializeObject <ReturnedResult>(ret);

            if (deserializedResult.result != null)
            {
                Console.WriteLine(deserializedResult.result);
            }
            return(int.Parse(deserializedResult.result));
        }
Exemple #2
0
        public static int GetBlockHeight()
        {
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(CreateCommand(getBlockCountCommand, new List <string> {
            })));

            webReq.Method        = "GET";
            webReq.ContentType   = "application/x-www-form-urlencoded";
            webReq.Timeout       = 6000000;
            webReq.ContentLength = 0;

            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            StreamReader    sr       = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            string          ret      = sr.ReadToEnd();

            sr.Close();
            response.Close();
            ReturnedResult deserializedResult = JsonConvert.DeserializeObject <ReturnedResult>(ret);
            int            result             = int.Parse(deserializedResult.result);

            return(result <= 0 ? -1 : result - 1);
        }