public void Connect(List <NodeAddress> allPortsInCluster, NodeAddress localAddress) { this.localAddress = localAddress; foreach (var nodeAddress in allPortsInCluster) { if (nodeAddress == localAddress) { continue; } var channel = new Channel($"{nodeAddress.Host}:{nodeAddress.Port}", ChannelCredentials.Insecure); var client = new P2PGrpc.P2PGrpcClient(channel); OutboundConnections.Add(nodeAddress, new OutboundConnection { Channel = channel, Client = client }); } }
public void CloseConnection(NodeAddress node) { OutboundConnections[node].Channel.ShutdownAsync().Wait(); }