/// <summary> /// Return the latest irreversible block. /// https://github.com/nebulasio/wiki/blob/master/rpc.md#latestirreversibleblock /// </summary> /// <returns></returns> public IrreversibleBlock LatestIrreversibleBlock() { IrreversibleBlock result = new IrreversibleBlock(); if (restUtils == null) { restUtils = new RestUtils(); } string resource = string.Format("{0}{1}", API_VERSION, Constant.LINK_LatestIrreversibleBlock); IRestResponse response = restUtils.Send(API_URL, resource); if (response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.OK) { try { result = JsonConvert.DeserializeObject <IrreversibleBlock>(response.Content); result.message = string.Empty; } catch (Exception ex) { result.message = ex.Message; } } else { result.message = response.ErrorMessage; } return(result); }
/// <summary> /// Get block header info by the block height. /// https://github.com/nebulasio/wiki/blob/master/rpc.md#getblockbyheight /// </summary> /// <param name="height">Height of transaction hash.</param> /// <param name="full_fill_transaction">If true it returns the full transaction objects, if false only the hashes of the transactions.</param> /// <returns></returns> public IrreversibleBlock GetBlockByHeight(Int64 height, bool full_fill_transaction) { IrreversibleBlock result = new IrreversibleBlock(); if (restUtils == null) { restUtils = new RestUtils(); } string resource = string.Format("{0}{1}", API_VERSION, Constant.LINK_GetBlockByHeight); Dictionary <string, object> paras = new Dictionary <string, object>(); paras.Add("height", height); paras.Add("full_fill_transaction", full_fill_transaction); IRestResponse response = restUtils.Post(API_URL, resource, paras); if (response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.OK) { try { result = JsonConvert.DeserializeObject <IrreversibleBlock>(response.Content); result.message = string.Empty; } catch (Exception ex) { result.message = ex.Message; } } else { result.message = response.ErrorMessage; } return(result); }