pub fn on_new_in_request(
        &mut self,
        peer: PeerId,
        request_id: RequestId,
        request: Rq,
        response_tx: oneshot::Sender<Rs>,
        connection: ConnectionId,
        approval_status: ApprovalStatus,
    ) {
        if !matches!(approval_status, ApprovalStatus::Rejected) {
            // Add request to the requests of the associated connection.
            // Return if the connection closed.
            let conn = self
                .connections
                .add_request(&peer, request_id, Some(connection), &RequestDirection::Inbound);
            if conn.is_none() {
                let action = BehaviourAction::InboundFailure {
                    request_id,
                    peer,
                    failure: InboundFailure::ConnectionClosed,
                };
                self.actions.push_back(action);
                return;
            }
        }
        match approval_status {
            ApprovalStatus::MissingRule => {
                // Add request to the list of requests that are awaiting a rule for that peer.
                self.inbound_request_store
                    .insert(request_id, (peer, request, response_tx));
                let await_rule = self.awaiting_peer_rule.entry(peer).or_default();
                await_rule
                    .entry(RequestDirection::Inbound)
                    .or_default()
                    .push(request_id);
            }
            ApprovalStatus::MissingApproval => {
                // Add request to the list of requests that are awaiting individual approval.
                self.inbound_request_store
                    .insert(request_id, (peer, request, response_tx));
                self.awaiting_approval.push((request_id, RequestDirection::Inbound));
            }
            ApprovalStatus::Approved => {
                let action = BehaviourAction::InboundOk {
                    request_id,
                    peer,
                    request,
                    response_tx,
                };
                self.actions.push_back(action);
            }
            ApprovalStatus::Rejected => {
                let action = BehaviourAction::InboundFailure {
                    request_id,
                    peer,
                    failure: InboundFailure::NotPermitted,
                };
                self.actions.push_back(action);
            }
        }
    }
// New inbound request that was received.
// Depending on the approval and connection status, the appropriate [`BehaviourAction`] will be issued
// and/ or the request will be cached if it is waiting for approval.
New inbound request that was received.
Depending on the approval and connection status, the appropriate [`BehaviourAction`] will be issued
and/ or the request will be cached if it is waiting for approval.
New inbound request that was received . Depending on the approval and connection status the appropriate [ ` BehaviourAction ` ] will be issued and / or the request will be cached if it is waiting for approval .
pub fn on_new_in_request(
        &mut self,
        peer: PeerId,
        request_id: RequestId,
        request: Rq,
        response_tx: oneshot::Sender<Rs>,
        connection: ConnectionId,
        approval_status: ApprovalStatus,
    ) {
        if !matches!(approval_status, ApprovalStatus::Rejected) {
            // Add request to the requests of the associated connection.
            // Return if the connection closed.
            let conn = self
                .connections
                .add_request(&peer, request_id, Some(connection), &RequestDirection::Inbound);
            if conn.is_none() {
                let action = BehaviourAction::InboundFailure {
                    request_id,
                    peer,
                    failure: InboundFailure::ConnectionClosed,
                };
                self.actions.push_back(action);
                return;
            }
        }
        match approval_status {
            ApprovalStatus::MissingRule => {
                // Add request to the list of requests that are awaiting a rule for that peer.
                self.inbound_request_store
                    .insert(request_id, (peer, request, response_tx));
                let await_rule = self.awaiting_peer_rule.entry(peer).or_default();
                await_rule
                    .entry(RequestDirection::Inbound)
                    .or_default()
                    .push(request_id);
            }
            ApprovalStatus::MissingApproval => {
                // Add request to the list of requests that are awaiting individual approval.
                self.inbound_request_store
                    .insert(request_id, (peer, request, response_tx));
                self.awaiting_approval.push((request_id, RequestDirection::Inbound));
            }
            ApprovalStatus::Approved => {
                let action = BehaviourAction::InboundOk {
                    request_id,
                    peer,
                    request,
                    response_tx,
                };
                self.actions.push_back(action);
            }
            ApprovalStatus::Rejected => {
                let action = BehaviourAction::InboundFailure {
                    request_id,
                    peer,
                    failure: InboundFailure::NotPermitted,
                };
                self.actions.push_back(action);
            }
        }
    }
pub fn on_new_in_request ( & mut self , peer : PeerId , request_id : RequestId , request : Rq , response_tx : oneshot :: Sender < Rs > , connection : ConnectionId , approval_status : ApprovalStatus , ) { if ! matches ! ( approval_status ApprovalStatus Rejected ) { // Add request to the requests of the associated connection. // Return if the connection closed. let conn = self . connections . add_request ( & peer , request_id , Some ( connection ) , & RequestDirection :: Inbound ) ; if conn . is_none ( ) { let action = BehaviourAction :: InboundFailure { request_id , peer , failure : InboundFailure :: ConnectionClosed , } ; self . actions . push_back ( action ) ; return ; } } match approval_status { ApprovalStatus :: MissingRule => { // Add request to the list of requests that are awaiting a rule for that peer. self . inbound_request_store . insert ( request_id , ( peer , request , response_tx ) ) ; let await_rule = self . awaiting_peer_rule . entry ( peer ) . or_default ( ) ; await_rule . entry ( RequestDirection :: Inbound ) . or_default ( ) . push ( request_id ) ; } ApprovalStatus :: MissingApproval => { // Add request to the list of requests that are awaiting individual approval. self . inbound_request_store . insert ( request_id , ( peer , request , response_tx ) ) ; self . awaiting_approval . push ( ( request_id , RequestDirection :: Inbound ) ) ; } ApprovalStatus :: Approved => { let action = BehaviourAction :: InboundOk { request_id , peer , request , response_tx , } ; self . actions . push_back ( action ) ; } ApprovalStatus :: Rejected => { let action = BehaviourAction :: InboundFailure { request_id , peer , failure : InboundFailure :: NotPermitted , } ; self . actions . push_back ( action ) ; } } }
New inbound request that was received.
New inbound request that was received .
&mut self
peer
PeerId
request_id
RequestId
request
Rq
response_tx
oneshot::Sender<Rs>
connection
ConnectionId
approval_status
ApprovalStatus
&mut self
peer
PeerId
request_id
RequestId
request
Rq
response_tx
oneshot::Sender<Rs>
connection
ConnectionId
approval_status
ApprovalStatus