// Output the response of a subnet message depending on its type.
//
// Canister requests are responded to by adding a response to the subnet's
// output queue. Ingress requests are responded to by writing to ingress
// history.
Output the response of a subnet message depending on its type.
Canister requests are responded to by adding a response to the subnet's
output queue. Ingress requests are responded to by writing to ingress
history.
Output the response of a subnet message depending on its type . Canister requests are responded to by adding a response to the subnet ' s output queue . Ingress requests are responded to by writing to ingress history .
fn output_subnet_response(
        &self,
        msg: RequestOrIngress,
        mut state: ReplicatedState,
        result: Result<Vec<u8>, UserError>,
        refund: Cycles,
    ) -> ReplicatedState {
        match msg {
            RequestOrIngress::Request(req) => {
                let payload = match result {
                    Ok(payload) => Payload::Data(payload),
                    Err(err) => Payload::Reject(err.into()),
                };
                let subnet_id_as_canister_id = CanisterId::from(self.own_subnet_id);
                let response = Response {
                    originator: req.sender,
                    respondent: subnet_id_as_canister_id,
                    originator_reply_callback: req.sender_reply_callback,
                    refund,
                    response_payload: payload,
                };
                state.push_subnet_output_response(response);
                state
            }
            RequestOrIngress::Ingress(ingress) => {
                if !refund.is_zero() {
                    warn!(
                        self.log,
                        "[EXC-BUG] No funds can be included with an ingress message: user {}, canister_id {}, message_id {}.",
                        ingress.source, ingress.receiver, ingress.message_id
                    );
                }
                let status = match result {
                    Ok(payload) => IngressStatus::Completed {
                        receiver: ingress.receiver.get(),
                        user_id: ingress.source,
                        result: WasmResult::Reply(payload),
                        time: state.time(),
                    },
                    Err(err) => IngressStatus::Failed {
                        receiver: ingress.receiver.get(),
                        user_id: ingress.source,
                        error: err,
                        time: state.time(),
                    },
                };
                self.ingress_history_writer
                    .set_status(&mut state, ingress.message_id, status);
                state
            }
        }
    }
fn output_subnet_response ( & self , msg : RequestOrIngress , mut state : ReplicatedState , result : Result < Vec < u8 > , UserError > , refund : Cycles , ) -> ReplicatedState { match msg { RequestOrIngress :: Request ( req ) => { let payload = match result { Ok ( payload ) => Payload :: Data ( payload ) , Err ( err ) => Payload :: Reject ( err . into ( ) ) , } ; let subnet_id_as_canister_id = CanisterId :: from ( self . own_subnet_id ) ; let response = Response { originator : req . sender , respondent : subnet_id_as_canister_id , originator_reply_callback : req . sender_reply_callback , refund , response_payload : payload , } ; state . push_subnet_output_response ( response ) ; state } RequestOrIngress :: Ingress ( ingress ) => { if ! refund . is_zero ( ) { warn ! ( self log " " ingress source ingress receiver ingress message_id ) ; } let status = match result { Ok ( payload ) => IngressStatus :: Completed { receiver : ingress . receiver . get ( ) , user_id : ingress . source , result : WasmResult :: Reply ( payload ) , time : state . time ( ) , } , Err ( err ) => IngressStatus :: Failed { receiver : ingress . receiver . get ( ) , user_id : ingress . source , error : err , time : state . time ( ) , } , } ; self . ingress_history_writer . set_status ( & mut state , ingress . message_id , status ) ; state } } }
Output the response of a subnet message depending on its type.
Output the response of a subnet message depending on its type .
&self
msg
RequestOrIngress
state
ReplicatedState
result
Result<Vec<u8>, UserError>
refund
Cycles