示例#1
0
        async Task PingOldestLoop()
        {
            while (!_node.HasQuit)
            {
                await Task.Delay(Time.Minutes(5), _node.QuitToken); // ping oldest every 5 minutes

                if (_node.HasQuit)
                {
                    return;
                }

                try
                {
                    var oldest = _bucket.GetOldestNodes();

                    foreach (var node in oldest)
                    {
                        if (node.IsPublicEndPoint)
                        {
                            if (!await QueryEndPoint(node.PublicEndPoint, false))
                            {
                                _bucket.Remove(node.NodeId);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.IgnoreException(ex, this);
                }
            }
        }