/// Peers that have been returned by discovery requests are dialed here if they are suitable.
///
/// NOTE: By dialing `PeerId`s and not multiaddrs, libp2p requests the multiaddr associated
/// with a new `PeerId` which involves a discovery routing table lookup. We could dial the
/// multiaddr here, however this could relate to duplicate PeerId's etc. If the lookup
/// proves resource constraining, we should switch to multiaddr dialling here.
Peers that have been returned by discovery requests are dialed here if they are suitable.
NOTE: By dialing `PeerId`s and not multiaddrs, libp2p requests the multiaddr associated
with a new `PeerId` which involves a discovery routing table lookup. We could dial the
multiaddr here, however this could relate to duplicate PeerId's etc. If the lookup
proves resource constraining, we should switch to multiaddr dialling here.
Peers that have been returned by discovery requests are dialed here if they are suitable . NOTE : By dialing ` PeerId ` s and not multiaddrs libp2p requests the multiaddr associated with a new ` PeerId ` which involves a discovery routing table lookup . We could dial the multiaddr here however this could relate to duplicate PeerId ' s etc . If the lookup proves resource constraining we should switch to multiaddr dialling here .
fn peers_discovered(&mut self, peers: &[Enr], min_ttl: Option<Instant>) {
        for enr in peers {
            let peer_id = enr.peer_id();
            // if we need more peers, attempt a connection
            if self.network_globals.connected_or_dialing_peers() < self.target_peers
                && !self
                    .network_globals
                    .peers
                    .read()
                    .is_connected_or_dialing(&peer_id)
                && !self.network_globals.peers.read().peer_banned(&peer_id)
            {
                debug!(self.log, "Dialing discovered peer"; "peer_id"=> peer_id.to_string());
                // TODO: Update output
                // This should be updated with the peer dialing. In fact created once the peer is
                // dialed
                if let Some(min_ttl) = min_ttl {
                    self.network_globals
                        .peers
                        .write()
                        .update_min_ttl(&peer_id, min_ttl);
                }
                self.events.push(PeerManagerEvent::Dial(peer_id));
            }
        }
    }
fn peers_discovered ( & mut self , peers : & [ Enr ] , min_ttl : Option < Instant > ) { for enr in peers { let peer_id = enr . peer_id ( ) ; // if we need more peers, attempt a connection if self . network_globals . connected_or_dialing_peers ( ) < self . target_peers && ! self . network_globals . peers . read ( ) . is_connected_or_dialing ( & peer_id ) && ! self . network_globals . peers . read ( ) . peer_banned ( & peer_id ) { debug ! ( self log " " " " peer_id to_string ( ) ) ; // TODO: Update output // This should be updated with the peer dialing. In fact created once the peer is // dialed if let Some ( min_ttl ) = min_ttl { self . network_globals . peers . write ( ) . update_min_ttl ( & peer_id , min_ttl ) ; } self . events . push ( PeerManagerEvent :: Dial ( peer_id ) ) ; } } }
Peers that have been returned by discovery requests are dialed here if they are suitable.
Peers that have been returned by discovery requests are dialed here if they are suitable .
&mut self
peers
&[Enr]
min_ttl
Option<Instant>