/// Registers a peer as connected. The `ingoing` parameter determines if the peer is being
/// dialed or connecting to us.
///
/// This is called by `connect_ingoing` and `connect_outgoing`.
///
/// This informs if the peer was accepted in to the db or not.
// TODO: Drop peers if over max_peer limit
Registers a peer as connected. The `ingoing` parameter determines if the peer is being
dialed or connecting to us.

This is called by `connect_ingoing` and `connect_outgoing`.

This informs if the peer was accepted in to the db or not.
TODO: Drop peers if over max_peer limit
Registers a peer as connected . The ` ingoing ` parameter determines if the peer is being dialed or connecting to us . This is called by ` connect_ingoing ` and ` connect_outgoing ` . This informs if the peer was accepted in to the db or not . TODO : Drop peers if over max_peer limit
fn connect_peer(&mut self, peer_id: &PeerId, connection: ConnectingType) -> bool {
        // TODO: remove after timed updates
        //self.update_reputations();
        {
            let mut peerdb = self.network_globals.peers.write();
            if peerdb.connection_status(peer_id).map(|c| c.is_banned()) == Some(true) {
                // don't connect if the peer is banned
                // TODO: Handle this case. If peer is banned this shouldn't be reached. It will put
                // our connection/disconnection out of sync with libp2p
                // return false;
            }
            match connection {
                ConnectingType::Dialing => peerdb.dialing_peer(peer_id),
                ConnectingType::IngoingConnected => peerdb.connect_outgoing(peer_id),
                ConnectingType::OutgoingConnected => peerdb.connect_ingoing(peer_id),
            }
        }
        // start a ping and status timer for the peer
        self.ping_peers.insert(peer_id.clone());
        self.status_peers.insert(peer_id.clone());
        true
    }
fn connect_peer ( & mut self , peer_id : & PeerId , connection : ConnectingType ) -> bool { // TODO: remove after timed updates //self.update_reputations(); { let mut peerdb = self . network_globals . peers . write ( ) ; if peerdb . connection_status ( peer_id ) . map ( | c | c . is_banned ( ) ) == Some ( true ) { // don't connect if the peer is banned // TODO: Handle this case. If peer is banned this shouldn't be reached. It will put // our connection/disconnection out of sync with libp2p // return false; } match connection { ConnectingType :: Dialing => peerdb . dialing_peer ( peer_id ) , ConnectingType :: IngoingConnected => peerdb . connect_outgoing ( peer_id ) , ConnectingType :: OutgoingConnected => peerdb . connect_ingoing ( peer_id ) , } } // start a ping and status timer for the peer self . ping_peers . insert ( peer_id . clone ( ) ) ; self . status_peers . insert ( peer_id . clone ( ) ) ; true }
Registers a peer as connected.
Registers a peer as connected .
&mut self
peer_id
&PeerId
connection
ConnectingType