// Handle an individual connection closing.
// Emit failures for the pending responses on that connection.
Handle an individual connection closing.
Emit failures for the pending responses on that connection.
Handle an individual connection closing . Emit failures for the pending responses on that connection .
pub fn on_connection_closed(&mut self, peer: PeerId, connection: &ConnectionId) {
        let pending_res = self.connections.remove_connection(peer, connection);
        if let Some(pending_res) = pending_res {
            for request_id in pending_res.outbound_requests {
                self.actions.push_back(BehaviourAction::OutboundFailure {
                    request_id,
                    peer,
                    failure: OutboundFailure::ConnectionClosed,
                })
            }
            for request_id in pending_res.inbound_requests {
                // Remove request from all queues and lists.
                self.awaiting_approval.retain(|(r, _)| r != &request_id);
                if let Some(requests) = self
                    .awaiting_peer_rule
                    .get_mut(&peer)
                    .and_then(|r| r.get_mut(&RequestDirection::Inbound))
                {
                    requests.retain(|r| r != &request_id)
                }
                self.inbound_request_store.remove(&request_id);
                self.actions.push_back(BehaviourAction::InboundFailure {
                    request_id,
                    peer,
                    failure: InboundFailure::ConnectionClosed,
                })
            }
        }
    }
pub fn on_connection_closed ( & mut self , peer : PeerId , connection : & ConnectionId ) { let pending_res = self . connections . remove_connection ( peer , connection ) ; if let Some ( pending_res ) = pending_res { for request_id in pending_res . outbound_requests { self . actions . push_back ( BehaviourAction :: OutboundFailure { request_id , peer , failure : OutboundFailure :: ConnectionClosed , } ) } for request_id in pending_res . inbound_requests { // Remove request from all queues and lists. self . awaiting_approval . retain ( | ( r , _ ) | r != & request_id ) ; if let Some ( requests ) = self . awaiting_peer_rule . get_mut ( & peer ) . and_then ( | r | r . get_mut ( & RequestDirection :: Inbound ) ) { requests . retain ( | r | r != & request_id ) } self . inbound_request_store . remove ( & request_id ) ; self . actions . push_back ( BehaviourAction :: InboundFailure { request_id , peer , failure : InboundFailure :: ConnectionClosed , } ) } } }
Handle an individual connection closing.
Handle an individual connection closing .
&mut self
peer
PeerId
connection
&ConnectionId