// Returns whether or not a peer is connected already private bool IsPeerConnected(PeerCandidate Peer) { // Check whether the peer candidate is this node if (Peer.Id == Id) { return(true); } // Lock peer list to prevent race conditions lock (PeerList) { // Check if the connected peer list contains this peer if (PeerList.Any(x => x.Id == Peer.Id)) { return(true); } // Check if any incoming connections have this address + port if (P2pServer.PendingConnections.Any(x => x.Client.RemoteEndPoint.ToString() == $"{Peer.Address}:{Peer.Port}")) { return(true); } } // Peer is not connected return(false); }
// Returns whether or not a peer is connected already private bool IsPeerConnected(PeerCandidate Peer) { // Check whether the peer candidate is this node if (Peer.Id == Id) { return(true); } // Lock peer list to prevent race conditions lock (PeerList) { // Check if the connected peer list contains this peer if (PeerList.Any(x => x.Id == Peer.Id)) { return(true); } // TODO - check if incoming connections has this address+port } // Peer is not connected return(false); }