/// <summary> /// gets the total number of transactions in the block /// </summary> /// <returns></returns> public Tuple <bool, string, GetBlockHeightResBody> GetTxCountByBlockNumber(string blockNumber) { try { NodeApiReqBody <FiscoBlockReqDataBody> req = new NodeApiReqBody <FiscoBlockReqDataBody> { header = GetReqHeader(), body = new FiscoBlockReqDataBody() { BlockNumber = blockNumber } }; req.mac = sign.Sign(FiscoReqMacExtends.GetFiscoBlockInfoReqMac(req)); var res = SendHelper.SendPost <NodeApiResBody <GetBlockHeightResBody> >(config.reqUrl + GetTxCountByBlockNumberUrl, JsonConvert.SerializeObject(req), config.httpsCert); if (res != null) { //Check the status codes in turn if (res.header.code != 0) { return(new Tuple <bool, string, GetBlockHeightResBody>(false, res.header.msg, null)); } //assemble the original string to verify var datares = FiscoResMacExtends.GetBlockHeightResMac(res); //data verified if (sign.Verify(res.mac, datares)) { return(new Tuple <bool, string, GetBlockHeightResBody>(true, res.header.msg, res.body)); } else { return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to verify the signature", null)); } } } catch (Exception ex) { throw ex; } return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to get the total number of transactions in the block", null)); }
/// <summary> /// Get application block height information /// </summary> /// <returns></returns> public Tuple <bool, string, GetBlockHeightResBody> GetBlockHeight() { try { NodeApiReq req = new NodeApiReq() { header = GetReqHeader() }; req.mac = sign.Sign(FiscoReqMacExtends.GetReqHeaderMac(req.header)); var res = SendHelper.SendPost <NodeApiResBody <GetBlockHeightResBody> >(config.reqUrl + GetBlockHeightUrl, JsonConvert.SerializeObject(req), config.httpsCert); if (res != null) { //Check the status codes in turn if (res.header.code != 0) { return(new Tuple <bool, string, GetBlockHeightResBody>(false, res.header.msg, null)); } //assemble the original string to verify var datares = FiscoResMacExtends.GetBlockHeightResMac(res); //data verified if (sign.Verify(res.mac, datares)) { return(new Tuple <bool, string, GetBlockHeightResBody>(true, res.header.msg, res.body)); } else { return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to verify the signature", null)); } } } catch (Exception ex) { throw ex; } return(new Tuple <bool, string, GetBlockHeightResBody>(false, "failed to get the block height in the application", null)); }