pub fn on_peer_connected(&mut self, peer: PeerId) {
        // Check that there is at least one active connection to the remote.
        if !self.connections.is_connected(&peer) {
            return;
        }
        // Handle pending requests
        if let Some(requests) = self.awaiting_connection.remove(&peer) {
            requests.into_iter().for_each(|request_id| {
                let (peer, request) = unwrap_or_return!(self.outbound_request_store.remove(&request_id));
                let connection = self
                    .connections
                    .add_request(&peer, request_id, None, &RequestDirection::Outbound)
                    .expect("Peer is connected");
                let action = BehaviourAction::OutboundOk {
                    request_id,
                    peer,
                    request,
                    connection,
                };
                self.actions.push_back(action);
            });
        }
    }
// Handle a newly connected peer i.g. that at least one connection was established.
// Assign pending request to a connection and mark them as ready.
Handle a newly connected peer i.g. that at least one connection was established.
Assign pending request to a connection and mark them as ready.
Handle a newly connected peer i . g . that at least one connection was established . Assign pending request to a connection and mark them as ready .
pub fn on_peer_connected(&mut self, peer: PeerId) {
        // Check that there is at least one active connection to the remote.
        if !self.connections.is_connected(&peer) {
            return;
        }
        // Handle pending requests
        if let Some(requests) = self.awaiting_connection.remove(&peer) {
            requests.into_iter().for_each(|request_id| {
                let (peer, request) = unwrap_or_return!(self.outbound_request_store.remove(&request_id));
                let connection = self
                    .connections
                    .add_request(&peer, request_id, None, &RequestDirection::Outbound)
                    .expect("Peer is connected");
                let action = BehaviourAction::OutboundOk {
                    request_id,
                    peer,
                    request,
                    connection,
                };
                self.actions.push_back(action);
            });
        }
    }
pub fn on_peer_connected ( & mut self , peer : PeerId ) { // Check that there is at least one active connection to the remote. if ! self . connections . is_connected ( & peer ) { return ; } // Handle pending requests if let Some ( requests ) = self . awaiting_connection . remove ( & peer ) { requests . into_iter ( ) . for_each ( | request_id | { let ( peer , request ) = unwrap_or_return ! ( self outbound_request_store remove ( request_id ) ) ; let connection = self . connections . add_request ( & peer , request_id , None , & RequestDirection :: Outbound ) . expect ( " " ) ; let action = BehaviourAction :: OutboundOk { request_id , peer , request , connection , } ; self . actions . push_back ( action ) ; } ) ; } }
Handle a newly connected peer i.g.
Handle a newly connected peer i . g .
&mut self
peer
PeerId
&mut self
peer
PeerId