public async Task GetBlockChainStatus() { BlockChainEngine engine = new BlockChainEngine(); BlockChainStatusOM result = await engine.GetBlockChainStatus(); Assert.IsNotNull(result); }
public async Task <BlockChainStatusOM> GetBlockChainStatus() { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri(WalletNetwork.NetWork), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithNoParameters("GetBlockChainStatus", 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } BlockChainStatusOM responseValue = response.GetResult <BlockChainStatusOM>(); return(responseValue); }
public static async Task <ApiResponse> GetBlockChainStatus() { ApiResponse response = new ApiResponse(); try { BlockChainEngine engine = new BlockChainEngine(); BlockChainStatus status = new BlockChainStatus(); BlockChainStatusOM result = await engine.GetBlockChainStatus(); if (result != null) { status.ChainService = result.ChainService; status.BlockService = result.BlockService; status.P2pService = result.P2pService; status.RpcService = result.RpcService; status.ChainNetwork = result.ChainNetwork; status.Height = result.Height; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(status); } 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); }