public static async Task <ApiResponse> GetBlockHeader(string hash, int formate = 0) { ApiResponse response = new ApiResponse(); try { BlockChainEngine engine = new BlockChainEngine(); BlockHeaderOM result = await engine.GetBlockHeader(hash, formate); 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); }
public async Task GetBlockHeader() { BlockChainEngine engine = new BlockChainEngine(); BlockHeaderOM result = await engine.GetBlockHeader("B6D9FD10775254A86E836F211205D8A21D0F3FF3821C9E6F1F99377BFB4DADFA", 1); Assert.IsNotNull(result); }
public async Task GetBlockHeader() { ApiResponse response = await BlockChainEngineApi.GetBlockHeader("B6D9FD10775254A86E836F211205D8A21D0F3FF3821C9E6F1F99377BFB4DADFA", 1); Assert.IsFalse(response.HasError); if (response.Result != null) { BlockHeaderOM result = response.GetResult <BlockHeaderOM>(); Assert.IsNotNull(result); } else { Assert.IsNull(response.Result); } }
public async Task <BlockHeaderOM> GetBlockHeader(string hash, int formate = 0) { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri(WalletNetwork.NetWork), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithParameterList("GetBlockHeader", new List <object> { hash, formate }, 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } BlockHeaderOM responseValue = response.GetResult <BlockHeaderOM>(); return(responseValue); }