示例#1
0
        /**
         * Return a list of peer in G2 network (simple leaf or ultra peer)
         * from the file downloaded precedently
         * */
        private List <NodePeer> ParsePeerList()
        {
            if (!fileExists())
            {
                return(null);
            }

            List <NodePeer> peers = new List <NodePeer> ();
            StreamReader    file  = new StreamReader(FileName);
            string          line  = "";
            int             count = 0;

            while ((line = file.ReadLine()) != null)
            {
                try {
                    NodePeer h = NodePeer.Parse(line);
                    peers.Add(h);
                    count++;
                } catch (FormatException e) {
                                        #if DEBUG
                    //Console.Error.WriteLine (e);
                                        #endif
                }
            }
            if (peers.Count == 0)
            {
                Console.Error.WriteLine("No peer found");
                return(null);
            }

            G2Log.Write("GWebCache : Found " + peers.Count + " peers ...");
            return(peers);
        }