pub async fn update(&mut self) -> Result<(), BoxError> {
        // Opportunistically crawl the network on every update call to ensure
        // we're actively fetching peers. Continue independently of whether we
        // actually receive any peers, but always ask the network for more.
        // Because requests are load-balanced across existing peers, we can make
        // multiple requests concurrently, which will be randomly assigned to
        // existing peers, but we don't make too many because update may be
        // called while the peer set is already loaded.
        let mut responses = FuturesUnordered::new();
        trace!("sending GetPeers requests");
        // Yes this loops only once (for now), until we add fanout back.
        for _ in 0..1usize {
            self.peer_service.ready_and().await?;
            responses.push(self.peer_service.call(Request::Peers));
        }
        while let Some(rsp) = responses.next().await {
            if let Ok(Response::Peers(rsp_addrs)) = rsp {
                // Filter new addresses to ensure that gossiped addresses are actually new
                let peer_set = &self.peer_set;
                let new_addrs = rsp_addrs
                    .iter()
                    .filter(|meta| !peer_set.lock().unwrap().contains_addr(&meta.addr))
                    .collect::<Vec<_>>();
                trace!(
                    ?rsp_addrs,
                    new_addr_count = ?new_addrs.len(),
                    "got response to GetPeers"
                );
                // New addresses are deserialized in the `NeverAttempted` state
                peer_set
                    .lock()
                    .unwrap()
                    .extend(new_addrs.into_iter().cloned());
            } else {
                trace!("got error in GetPeers request");
            }
        }

        Ok(())
    }
/// Update the peer set from the network.
///
/// - Ask a few live `Responded` peers to send us more peers.
/// - Process all completed peer responses, adding new peers in the
///   `NeverAttempted` state.
///
/// ## Correctness
///
/// The handshaker sets up the peer message receiver so it also sends a
/// `Responded` peer address update.
///
/// `report_failed` puts peers into the `Failed` state.
///
/// `next` puts peers into the `AttemptPending` state.
Update the peer set from the network.
Ask a few live `Responded` peers to send us more peers.
Process all completed peer responses, adding new peers in the
`NeverAttempted` state.
Update the peer set from the network . Ask a few live ` Responded ` peers to send us more peers . Process all completed peer responses adding new peers in the ` NeverAttempted ` state .
pub async fn update(&mut self) -> Result<(), BoxError> {
        // Opportunistically crawl the network on every update call to ensure
        // we're actively fetching peers. Continue independently of whether we
        // actually receive any peers, but always ask the network for more.
        // Because requests are load-balanced across existing peers, we can make
        // multiple requests concurrently, which will be randomly assigned to
        // existing peers, but we don't make too many because update may be
        // called while the peer set is already loaded.
        let mut responses = FuturesUnordered::new();
        trace!("sending GetPeers requests");
        // Yes this loops only once (for now), until we add fanout back.
        for _ in 0..1usize {
            self.peer_service.ready_and().await?;
            responses.push(self.peer_service.call(Request::Peers));
        }
        while let Some(rsp) = responses.next().await {
            if let Ok(Response::Peers(rsp_addrs)) = rsp {
                // Filter new addresses to ensure that gossiped addresses are actually new
                let peer_set = &self.peer_set;
                let new_addrs = rsp_addrs
                    .iter()
                    .filter(|meta| !peer_set.lock().unwrap().contains_addr(&meta.addr))
                    .collect::<Vec<_>>();
                trace!(
                    ?rsp_addrs,
                    new_addr_count = ?new_addrs.len(),
                    "got response to GetPeers"
                );
                // New addresses are deserialized in the `NeverAttempted` state
                peer_set
                    .lock()
                    .unwrap()
                    .extend(new_addrs.into_iter().cloned());
            } else {
                trace!("got error in GetPeers request");
            }
        }
        Ok(())
    }
pub async fn update ( & mut self ) -> Result < ( ) , BoxError > { // Opportunistically crawl the network on every update call to ensure // we're actively fetching peers. Continue independently of whether we // actually receive any peers, but always ask the network for more. // Because requests are load-balanced across existing peers, we can make // multiple requests concurrently, which will be randomly assigned to // existing peers, but we don't make too many because update may be // called while the peer set is already loaded. let mut responses = FuturesUnordered :: new ( ) ; trace ! ( " " ) ; // Yes this loops only once (for now), until we add fanout back. for _ in 0 .. 1usize { self . peer_service . ready_and ( ) . await ? ; responses . push ( self . peer_service . call ( Request :: Peers ) ) ; } while let Some ( rsp ) = responses . next ( ) . await { if let Ok ( Response :: Peers ( rsp_addrs ) ) = rsp { // Filter new addresses to ensure that gossiped addresses are actually new let peer_set = & self . peer_set ; let new_addrs = rsp_addrs . iter ( ) . filter ( | meta | ! peer_set . lock ( ) . unwrap ( ) . contains_addr ( & meta . addr ) ) . collect :: < Vec < _ > > ( ) ; trace ! ( rsp_addrs new_addr_count new_addrs len ( ) " " ) ; // New addresses are deserialized in the `NeverAttempted` state peer_set . lock ( ) . unwrap ( ) . extend ( new_addrs . into_iter ( ) . cloned ( ) ) ; } else { trace ! ( " " ) ; } } Ok ( ( ) ) }
Update the peer set from the network.
Update the peer set from the network .
&mut self
correctness
The handshaker sets up the peer message receiver so it also sends a
`Responded` peer address update.

`report_failed` puts peers into the `Failed` state.

`next` puts peers into the `AttemptPending` state.
The handshaker sets up the peer message receiver so it also sends a ` Responded ` peer address update . ` report_failed ` puts peers into the ` Failed ` state . ` next ` puts peers into the ` AttemptPending ` state .