private async Task <bool> ConnectAsync(ClientRpcInfo clientRpcInfo) { var isConnectionSuccessful = await clientRpcInfo.RpcClient .ConnectRetryAsync(clientRpcInfo.PeerId).ConfigureAwait(false); if (!isConnectionSuccessful) { _userOutput.WriteLine($"Could not connect to node: {clientRpcInfo.PeerId.Ip}:{clientRpcInfo.PeerId.Port}"); return(false); } clientRpcInfo.RpcClient.ReceiveMessage <BroadcastRawTransactionResponse>(ReceiveTransactionResponse); return(true); }
public static IEnumerable <ClientRpcInfo> GenerateClientRpcInfoFromConfig(IUserOutput userOutput, IPasswordRegistry passwordRegistry, X509Certificate2 certificate, ILogger logger, SigningContext signingContext) { var simulationNodesFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "simulation.nodes.json"); var simulationNodes = JsonConvert.DeserializeObject <List <SimulationNode> >(File.ReadAllText(simulationNodesFile)); foreach (var simulationNode in simulationNodes) { var simpleRpcClient = new SimpleRpcClient(userOutput, passwordRegistry, certificate, logger, signingContext); var clientRpcInfo = new ClientRpcInfo(simulationNode.ToPeerIdentifier(), simpleRpcClient); yield return(clientRpcInfo); } }