pub fn on_new_out_request(
        &mut self,
        peer: PeerId,
        request_id: RequestId,
        request: Rq,
        approval_status: ApprovalStatus,
    ) {
        match approval_status {
            ApprovalStatus::MissingRule => {
                // Add request to the list of requests that are awaiting a rule for that peer.
                self.outbound_request_store.insert(request_id, (peer, request));
                let await_rule = self.awaiting_peer_rule.entry(peer).or_default();
                await_rule
                    .entry(RequestDirection::Outbound)
                    .or_default()
                    .push(request_id);
            }
            ApprovalStatus::MissingApproval => {
                // Add request to the list of requests that are awaiting individual approval.
                self.outbound_request_store.insert(request_id, (peer, request));
                self.awaiting_approval.push((request_id, RequestDirection::Outbound));
            }
            ApprovalStatus::Approved => {
                // Request is ready to be send if a connection exists.
                // If no connection to the peer exists, add dial attempt.
                if let Some(connection) =
                    self.connections
                        .add_request(&peer, request_id, None, &RequestDirection::Outbound)
                {
                    // Request is approved and assigned to an existing connection.
                    let action = BehaviourAction::OutboundOk {
                        request_id,
                        peer,
                        request,
                        connection,
                    };
                    self.actions.push_back(action)
                } else {
                    self.outbound_request_store.insert(request_id, (peer, request));
                    self.add_dial_attempt(peer, request_id);
                }
            }
            ApprovalStatus::Rejected => {
                let action = BehaviourAction::OutboundFailure {
                    peer,
                    request_id,
                    failure: OutboundFailure::NotPermitted,
                };
                self.actions.push_back(action);
            }
        }
    }
// New outbound request that should be sent.
// 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 or connection.
New outbound request that should be sent.
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 or connection.
New outbound request that should be sent . 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 or connection .
pub fn on_new_out_request(
        &mut self,
        peer: PeerId,
        request_id: RequestId,
        request: Rq,
        approval_status: ApprovalStatus,
    ) {
        match approval_status {
            ApprovalStatus::MissingRule => {
                // Add request to the list of requests that are awaiting a rule for that peer.
                self.outbound_request_store.insert(request_id, (peer, request));
                let await_rule = self.awaiting_peer_rule.entry(peer).or_default();
                await_rule
                    .entry(RequestDirection::Outbound)
                    .or_default()
                    .push(request_id);
            }
            ApprovalStatus::MissingApproval => {
                // Add request to the list of requests that are awaiting individual approval.
                self.outbound_request_store.insert(request_id, (peer, request));
                self.awaiting_approval.push((request_id, RequestDirection::Outbound));
            }
            ApprovalStatus::Approved => {
                // Request is ready to be send if a connection exists.
                // If no connection to the peer exists, add dial attempt.
                if let Some(connection) =
                    self.connections
                        .add_request(&peer, request_id, None, &RequestDirection::Outbound)
                {
                    // Request is approved and assigned to an existing connection.
                    let action = BehaviourAction::OutboundOk {
                        request_id,
                        peer,
                        request,
                        connection,
                    };
                    self.actions.push_back(action)
                } else {
                    self.outbound_request_store.insert(request_id, (peer, request));
                    self.add_dial_attempt(peer, request_id);
                }
            }
            ApprovalStatus::Rejected => {
                let action = BehaviourAction::OutboundFailure {
                    peer,
                    request_id,
                    failure: OutboundFailure::NotPermitted,
                };
                self.actions.push_back(action);
            }
        }
    }
pub fn on_new_out_request ( & mut self , peer : PeerId , request_id : RequestId , request : Rq , approval_status : ApprovalStatus , ) { match approval_status { ApprovalStatus :: MissingRule => { // Add request to the list of requests that are awaiting a rule for that peer. self . outbound_request_store . insert ( request_id , ( peer , request ) ) ; let await_rule = self . awaiting_peer_rule . entry ( peer ) . or_default ( ) ; await_rule . entry ( RequestDirection :: Outbound ) . or_default ( ) . push ( request_id ) ; } ApprovalStatus :: MissingApproval => { // Add request to the list of requests that are awaiting individual approval. self . outbound_request_store . insert ( request_id , ( peer , request ) ) ; self . awaiting_approval . push ( ( request_id , RequestDirection :: Outbound ) ) ; } ApprovalStatus :: Approved => { // Request is ready to be send if a connection exists. // If no connection to the peer exists, add dial attempt. if let Some ( connection ) = self . connections . add_request ( & peer , request_id , None , & RequestDirection :: Outbound ) { // Request is approved and assigned to an existing connection. let action = BehaviourAction :: OutboundOk { request_id , peer , request , connection , } ; self . actions . push_back ( action ) } else { self . outbound_request_store . insert ( request_id , ( peer , request ) ) ; self . add_dial_attempt ( peer , request_id ) ; } } ApprovalStatus :: Rejected => { let action = BehaviourAction :: OutboundFailure { peer , request_id , failure : OutboundFailure :: NotPermitted , } ; self . actions . push_back ( action ) ; } } }
New outbound request that should be sent.
New outbound request that should be sent .
&mut self
peer
PeerId
request_id
RequestId
request
Rq
approval_status
ApprovalStatus
&mut self
peer
PeerId
request_id
RequestId
request
Rq
approval_status
ApprovalStatus