Exemplo n.º 1
0
        private void RequestMorePeersLoop()
        {
            while (true)
            {
                if (_peerTracker.NeedsMoreConnectedPeers)
                {
                    foreach (var remoteNode in _peerTracker.GetConnectedPeers())
                    {
                        if (!remoteNode.QueueContainsMessageType <RequestPeerAddressesMessage>())
                        {
                            remoteNode.QueueMessage(new RequestPeerAddressesMessage());
                            var transMessage = new TransactionMessage(new TransferTransaction());
                            remoteNode.QueueMessage(transMessage);
                        }
                    }

                    foreach (var endpoint in _peerTracker.GetNotConnectedEndPoints(Int32.MaxValue, 0))
                    {
                        Task.Run(() => ConnectToPeer(endpoint));
                    }

                    for (int i = 0; i < 50; i++)
                    {
                        Thread.Sleep(100);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ProcessMessage(RequestPeerAddressesMessage message, IRemoteNode remoteNode)
        {
            PeerAddressesPayloadMessage response = new PeerAddressesPayloadMessage();

            response.NotConnectedIpEndPoints = _peerTracker.GetNotConnectedEndPoints(Int32.MaxValue, 0);
            response.ConnectedIpEndPoints    = _peerTracker.GetConnectedEndPoints(Int32.MaxValue, 0);
            remoteNode.QueueMessage(response);
        }