public async Task Run() { var db = Redis.GetDatabase(); if (!await db.KeyExistsAsync("hs:nodes:all-nodes")) { Console.WriteLine("First run.. checking seeds"); //get seeds List <Node> allIps = new List <Node>(); foreach (var dseed in DNSSeeds) { var ips = await Dns.GetHostAddressesAsync(dseed); if (ips != null && ips.Length > 0) { allIps.AddRange(ips.Select(a => new Node() { IP = new IPEndPoint(a, 8333), LastSeen = new DateTime() })); } } foreach (var n in allIps) { await ParallelTasks.WaitAsync(); UpdateNodeInfo(n); ParallelTasks.Release(); } Console.WriteLine("First run complete."); } while (Running) { var nodes = await GetNewNodes(); foreach (var n in nodes) { await ParallelTasks.WaitAsync(); UpdateNodeInfo(n); ParallelTasks.Release(); } Console.WriteLine("Scrape complete."); await Task.Delay(30000); } }