예제 #1
0
        /// <summary>
        /// event  query
        /// </summary>
        /// <returns></returns>
        public Tuple <bool, string, QueryEventResData> EventQuery()
        {
            try
            {
                NodeApiReq req = new NodeApiReq()
                {
                    header = GetReqHeader()
                };
                req.mac = sign.Sign(FiscoReqMacExtends.GetReqHeaderMac(req.header));
                var res = SendHelper.SendPost <NodeApiResBody <QueryEventResData> >(config.reqUrl + EventQueryUrl, JsonConvert.SerializeObject(req), config.httpsCert);

                if (res != null)
                {
                    //Check the status codes in turn
                    if (res.header.code != 0)
                    {
                        return(new Tuple <bool, string, QueryEventResData>(false, res.header.msg, null));
                    }
                    //assemble the original string to verify
                    var datares = FiscoResMacExtends.GetFiscoQueryEventResMac(res);
                    //data verified
                    if (sign.Verify(res.mac, datares))
                    {
                        return(new Tuple <bool, string, QueryEventResData>(true, res.header.msg, res.body));
                    }
                    else
                    {
                        return(new Tuple <bool, string, QueryEventResData>(false, "failed to verify the signature", null));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new Tuple <bool, string, QueryEventResData>(false, "failed to query the chaincode", null));
        }
예제 #2
0
        /// <summary>
        /// gets the total number of transactions in the app
        /// </summary>
        /// <returns></returns>
        public Tuple <bool, string, GetBlockHeightResBody> GetTxCount()
        {
            try
            {
                NodeApiReq req = new NodeApiReq()
                {
                    header = GetReqHeader()
                };
                req.mac = sign.Sign(FiscoReqMacExtends.GetReqHeaderMac(req.header));
                var res = SendHelper.SendPost <NodeApiResBody <GetBlockHeightResBody> >(config.reqUrl + GetTxCountUrl, 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 app", null));
        }