Beispiel #1
0
        public async Task ConnectToPeerAsync(IPEndPoint remoteEndpoint)
        {
            if (remoteEndpoint.Equals(LocalEndpoint))
            {
                return;
            }
            RemoteNode remoteNode;

            lock (unconnectedPeers)
            {
                unconnectedPeers.Remove(remoteEndpoint);
            }
            lock (pendingPeers)
            {
                lock (connectedPeers)
                {
                    if (pendingPeers.Any(p => p.RemoteEndpoint == remoteEndpoint) || connectedPeers.ContainsKey(remoteEndpoint))
                    {
                        return;
                    }
                }
                remoteNode = new RemoteNode(this, remoteEndpoint);
                pendingPeers.Add(remoteNode);
                remoteNode.Disconnected        += RemoteNode_Disconnected;
                remoteNode.PeersReceived       += RemoteNode_PeersReceived;
                remoteNode.BlockReceived       += RemoteNode_BlockReceived;
                remoteNode.TransactionReceived += RemoteNode_TransactionReceived;
            }
            await remoteNode.ConnectAsync();
        }
Beispiel #2
0
        public async Task ConnectToPeerAsync(IPEndPoint remoteEndpoint)
        {
            if (remoteEndpoint.Port == Port && LocalAddresses.Contains(remoteEndpoint.Address))
            {
                return;
            }
            RemoteNode remoteNode;

            lock (unconnectedPeers)
            {
                unconnectedPeers.Remove(remoteEndpoint);
            }
            lock (pendingPeers)
            {
                lock (connectedPeers)
                {
                    if (pendingPeers.ContainsKey(remoteEndpoint) || connectedPeers.Any(p => remoteEndpoint.Equals(p.ListenerEndpoint)))
                    {
                        return;
                    }
                }
                remoteNode = new RemoteNode(this, remoteEndpoint);
                pendingPeers.Add(remoteEndpoint, remoteNode);
                remoteNode.Disconnected      += RemoteNode_Disconnected;
                remoteNode.InventoryReceived += RemoteNode_InventoryReceived;
                remoteNode.PeersReceived     += RemoteNode_PeersReceived;
            }
            await remoteNode.ConnectAsync();
        }
Beispiel #3
0
 public async Task ConnectToPeerAsync(IPEndPoint remoteEndpoint)
 {
     RemoteNode remoteNode;
     lock (unconnectedPeers)
     {
         unconnectedPeers.Remove(remoteEndpoint);
     }
     lock (pendingPeers)
     {
         lock (connectedPeers)
         {
             if (pendingPeers.Any(p => p.RemoteEndpoint == remoteEndpoint) || connectedPeers.ContainsKey(remoteEndpoint))
                 return;
         }
         remoteNode = new RemoteNode(this, remoteEndpoint);
         pendingPeers.Add(remoteNode);
         remoteNode.Disconnected += RemoteNode_Disconnected;
         remoteNode.NewInventory += RemoteNode_NewInventory;
         remoteNode.NewPeers += RemoteNode_NewPeers;
     }
     await remoteNode.ConnectAsync();
 }
Beispiel #4
0
 public async Task ConnectToPeerAsync(IPEndPoint remoteEndpoint)
 {
     RemoteNode remoteNode;
     lock (unconnectedPeers)
     {
         unconnectedPeers.Remove(remoteEndpoint);
     }
     lock (pendingPeers)
     {
         lock (connectedPeers)
         {
             if (pendingPeers.Any(p => p.RemoteEndpoint == remoteEndpoint) || connectedPeers.ContainsKey(remoteEndpoint))
                 return;
         }
         remoteNode = new RemoteNode(this, remoteEndpoint);
         pendingPeers.Add(remoteNode);
         remoteNode.Disconnected += RemoteNode_Disconnected;
         remoteNode.PeersReceived += RemoteNode_PeersReceived;
         remoteNode.BlockReceived += RemoteNode_BlockReceived;
         remoteNode.TransactionReceived += RemoteNode_TransactionReceived;
     }
     await remoteNode.ConnectAsync();
 }