コード例 #1
0
        public static async Task <ApiResponse> GenerateNewBlock(string minerName, string address, int format = 0)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                BlockChainEngine engine = new BlockChainEngine();
                BlockInfoOM      result = await engine.GenerateNewBlock(minerName, address, format);

                if (result != null)
                {
                    response.Result = Newtonsoft.Json.Linq.JToken.FromObject(result);
                }
                else
                {
                    response.Result = null;
                }
            }
            catch (ApiCustomException ex)
            {
                Logger.Singleton.Error(ex.Message);
                Logger.Singleton.Error("Api error code is:" + ex.ErrorCode.ToString());
                Logger.Singleton.Error("Api error reason is:" + ex.InnerException.ToString());
                response.Error = new ApiError(ex.ErrorCode, ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error(ex.Message);
                Logger.Singleton.Error("Custom error code is:" + ex.HResult);
                Logger.Singleton.Error("Custom error reason is:" + ex.InnerException);
                response.Error = new ApiError(ex.HResult, ex.Message);
            }
            return(response);
        }
コード例 #2
0
        public async Task GenerateNewBlock()
        {
            BlockChainEngine engine = new BlockChainEngine();
            BlockInfoOM      result = await engine.GenerateNewBlock("Zhangsan", "", 1);

            Assert.IsNotNull(result);
        }