Beispiel #1
0
        private bool ValidatePeers(Peers peers, Node node)
        {
            try
            {
                node.Refresh(peers);

                if (peers.genChanged)
                {
                    peers.refreshCount = 0;
                    node.RefreshPeers(peers);
                }
            }
            catch (Exception)
            {
                node.Close();
                throw;
            }

            if (node.peersCount == 0)
            {
                // Node is suspect because multiple seeds are used and node does not have any peers.
                if (fallback == null)
                {
                    fallback = node;
                }
                else
                {
                    node.Close();
                }
                return(false);
            }

            // Node is valid. Drop fallback if it exists.
            if (fallback != null)
            {
                if (Log.InfoEnabled())
                {
                    Log.Info("Skip orphan node: " + fallback);
                }
                fallback.Close();
                fallback = null;
            }
            return(true);
        }