Esempio n. 1
0
        /// <inheritdoc />
        public async Task RefreshTableAsync(TimeSpan maxAge, CancellationToken cancellationToken)
        {
            // TODO: Add timeout parameter for this method
            try
            {
                IReadOnlyList <BoundPeer> peers = _table.PeersToRefresh(maxAge);
                _logger.Verbose(
                    "Refreshing {CandidateCount} peers out of {PeerCount} peers...",
                    peers.Count,
                    _table.Peers.Count);

                List <Task> tasks = peers
                                    .Select(peer =>
                                            ValidateAsync(
                                                peer,
                                                _requestTimeout,
                                                cancellationToken))
                                    .ToList();

                await Task.WhenAll(tasks);

                cancellationToken.ThrowIfCancellationRequested();
            }
            catch (TimeoutException)
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Checks whether <see cref="Peer"/>s in <see cref="RoutingTable"/> is online by
        /// sending <see cref="Ping"/>.
        /// </summary>
        /// <param name="maxAge">Maximum age of peer to validate.</param>
        /// <param name="cancellationToken">A cancellation token used to propagate notification
        /// that this operation should be canceled.</param>
        /// <returns>An awaitable task without value.</returns>
        public async Task RefreshTableAsync(TimeSpan maxAge, CancellationToken cancellationToken)
        {
            try
            {
                _logger.Debug("Refreshing table... total peers: {Count}", _routing.Peers.Count());
                List <Task> tasks = _routing.PeersToRefresh(maxAge)
                                    .Select(peer =>
                                            ValidateAsync(
                                                peer,
                                                _requestTimeout,
                                                cancellationToken)
                                            ).ToList();

                _logger.Debug("Refresh candidates: {Count}", tasks.Count);

                await Task.WhenAll(tasks);

                cancellationToken.ThrowIfCancellationRequested();
            }
            catch (TimeoutException)
            {
            }
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async Task RefreshTableAsync(TimeSpan maxAge, CancellationToken cancellationToken)
        {
            // TODO: Add timeout parameter for this method
            try
            {
                _logger.Verbose("Refreshing table... total peers: {Count}", _table.Peers.Count());
                List <Task> tasks = _table.PeersToRefresh(maxAge)
                                    .Select(peer =>
                                            ValidateAsync(
                                                peer,
                                                _requestTimeout,
                                                cancellationToken)
                                            ).ToList();

                _logger.Verbose("Refresh candidates: {Count}", tasks.Count);

                await Task.WhenAll(tasks);

                cancellationToken.ThrowIfCancellationRequested();
            }
            catch (TimeoutException)
            {
            }
        }