pub async fn next(&mut self) -> Option<MetaAddr> {
        let current_deadline = self.next_peer_min_wait.deadline();
        let mut sleep = sleep_until(current_deadline + Self::MIN_PEER_CONNECTION_INTERVAL);
        mem::swap(&mut self.next_peer_min_wait, &mut sleep);

        // CORRECTNESS
        //
        // In this critical section, we hold the address mutex.
        //
        // To avoid deadlocks, the critical section:
        // - must not acquire any other locks
        // - must not await any futures
        //
        // To avoid hangs, any computation in the critical section should
        // be kept to a minimum.
        let reconnect = {
            let mut peer_set_guard = self.peer_set.lock().unwrap();
            // It's okay to early return here because we're returning None
            // instead of yielding the next connection.
            let reconnect = peer_set_guard.reconnection_peers().next()?;

            let reconnect = MetaAddr::new_reconnect(&reconnect.addr, &reconnect.services);
            peer_set_guard.update(reconnect);
            reconnect
        };

        // This is the line that is most relevant to the above ## Security section
        sleep.await;

        Some(reconnect)
    }
/// Returns the next candidate for a connection attempt, if any are available.
///
/// Returns peers in this order:
/// - oldest `Responded` that are not live
/// - newest `NeverAttempted`
/// - oldest `Failed`
///
/// Skips `AttemptPending` peers and live `Responded` peers.
///
/// ## Correctness
///
/// `AttemptPending` peers will become `Responded` if they respond, or
/// become `Failed` if they time out or provide a bad response.
///
/// Live `Responded` peers will stay live if they keep responding, or
/// become a reconnection candidate if they stop responding.
///
/// ## Security
///
/// Zebra resists distributed denial of service attacks by making sure that
/// new peer connections are initiated at least
/// `MIN_PEER_CONNECTION_INTERVAL` apart.
Returns the next candidate for a connection attempt, if any are available.

Skips `AttemptPending` peers and live `Responded` peers.
Returns the next candidate for a connection attempt if any are available . Skips ` AttemptPending ` peers and live ` Responded ` peers .
pub async fn next(&mut self) -> Option<MetaAddr> {
        let current_deadline = self.next_peer_min_wait.deadline();
        let mut sleep = sleep_until(current_deadline + Self::MIN_PEER_CONNECTION_INTERVAL);
        mem::swap(&mut self.next_peer_min_wait, &mut sleep);
        // CORRECTNESS
        //
        // In this critical section, we hold the address mutex.
        //
        // To avoid deadlocks, the critical section:
        // - must not acquire any other locks
        // - must not await any futures
        //
        // To avoid hangs, any computation in the critical section should
        // be kept to a minimum.
        let reconnect = {
            let mut peer_set_guard = self.peer_set.lock().unwrap();
            // It's okay to early return here because we're returning None
            // instead of yielding the next connection.
            let reconnect = peer_set_guard.reconnection_peers().next()?;
            let reconnect = MetaAddr::new_reconnect(&reconnect.addr, &reconnect.services);
            peer_set_guard.update(reconnect);
            reconnect
        };
        // This is the line that is most relevant to the above ## Security section
        sleep.await;
        Some(reconnect)
    }
pub async fn next ( & mut self ) -> Option < MetaAddr > { let current_deadline = self . next_peer_min_wait . deadline ( ) ; let mut sleep = sleep_until ( current_deadline + Self :: MIN_PEER_CONNECTION_INTERVAL ) ; mem :: swap ( & mut self . next_peer_min_wait , & mut sleep ) ; // CORRECTNESS // // In this critical section, we hold the address mutex. // // To avoid deadlocks, the critical section: // - must not acquire any other locks // - must not await any futures // // To avoid hangs, any computation in the critical section should // be kept to a minimum. let reconnect = { let mut peer_set_guard = self . peer_set . lock ( ) . unwrap ( ) ; // It's okay to early return here because we're returning None // instead of yielding the next connection. let reconnect = peer_set_guard . reconnection_peers ( ) . next ( ) ? ; let reconnect = MetaAddr :: new_reconnect ( & reconnect . addr , & reconnect . services ) ; peer_set_guard . update ( reconnect ) ; reconnect } ; // This is the line that is most relevant to the above ## Security section sleep . await ; Some ( reconnect ) }
Returns the next candidate for a connection attempt, if any are available.
Returns the next candidate for a connection attempt if any are available .
&mut self
correctness
`AttemptPending` peers will become `Responded` if they respond, or
become `Failed` if they time out or provide a bad response.

Live `Responded` peers will stay live if they keep responding, or
become a reconnection candidate if they stop responding.
` AttemptPending ` peers will become ` Responded ` if they respond or become ` Failed ` if they time out or provide a bad response . Live ` Responded ` peers will stay live if they keep responding or become a reconnection candidate if they stop responding .
security
Zebra resists distributed denial of service attacks by making sure that
new peer connections are initiated at least
`MIN_PEER_CONNECTION_INTERVAL` apart.
Zebra resists distributed denial of service attacks by making sure that new peer connections are initiated at least ` MIN_PEER_CONNECTION_INTERVAL ` apart .