public override async Task <bool> OnExecute()
        {
            watch.Restart();

            List <PeerInfo> peers = await statsHandler.Peers();

            watch.Stop();

            log.LogDebug($"Time taken to retrieve peers from node: {watch.Elapsed.TotalSeconds}. Processing {peers.Count} peers and updating database.");

            watch.Restart();

            // TODO: Look into potential optimization on updates, not replacing the whole document for all connected nodes all the time.
            foreach (PeerInfo peer in peers)
            {
                await data.InsertPeer(peer);
            }

            log.LogInformation($"Time taken to update peers in database: {watch.Elapsed.TotalSeconds}.");

            return(await Task.FromResult(false));
        }
Example #2
0
        public async Task <IActionResult> Peers()
        {
            System.Collections.Generic.List <Client.Types.PeerInfo> ret = await statsHandler.Peers();

            return(Ok(ret));
        }