/// <summary> /// If null is returned, no exception is thrown, so the test was successful. /// </summary> public static async Task <Exception> TestAsync(this RPCClient rpc) { try { await rpc.GetBlockchainInfoAsync().ConfigureAwait(false); } catch (Exception ex) { return(ex); } return(null); }
public static async Task <RpcStatus> GetRpcStatusAsync(this RPCClient rpc, CancellationToken cancel) { try { var bci = await rpc.GetBlockchainInfoAsync().ConfigureAwait(false); cancel.ThrowIfCancellationRequested(); var pi = await rpc.GetPeersInfoAsync().ConfigureAwait(false); return(RpcStatus.Responsive(bci.Headers, bci.Blocks, pi.Length)); } catch (Exception ex) when(!(ex is OperationCanceledException || ex is TaskCanceledException || ex is TimeoutException)) { Logger.LogTrace(ex); return(RpcStatus.Unresponsive); } }