/// Executes the system method `canister_inspect_message`.
///
/// This method is called pre-consensus to let the canister decide if it
/// wants to accept the message or not.
Executes the system method `canister_inspect_message`.
This method is called pre-consensus to let the canister decide if it
wants to accept the message or not.
Executes the system method ` canister_inspect_message ` . This method is called pre - consensus to let the canister decide if it wants to accept the message or not .
pub fn execute_inspect_message(
        &self,
        canister: CanisterState,
        sender: PrincipalId,
        method_name: String,
        method_payload: Vec<u8>,
        time: Time,
        execution_parameters: ExecutionParameters,
    ) -> Result<(), CanonicalError> {
        let method = WasmMethod::System(SystemMethod::CanisterInspectMessage);
        let memory_usage = canister.memory_usage(self.own_subnet_type);
        let (execution_state, system_state, _) = canister.into_parts();
        // Validate that the Wasm module is present.
        let execution_state = match execution_state {
            None => return Err(not_found_error("Requested canister has no wasm module")),
            Some(execution_state) => execution_state,
        };
        // If the Wasm module does not export the method, then this execution
        // succeeds as a no-op.
        if !execution_state.exports_method(&method) {
            return Ok(());
        }
        let system_api = ApiType::inspect_message(sender, method_name, method_payload, time);
        let log = self.log.clone();
        let (output, _output_execution_state, _system_state_accessor) = self.execute(
            system_api,
            system_state,
            memory_usage,
            execution_parameters,
            FuncRef::Method(method),
            execution_state,
        );
        match output.wasm_result {
            Ok(maybe_wasm_result) => match maybe_wasm_result {
                None => Ok(()),
                Some(_result) => fatal!(
                    log,
                    "SystemApi should guarantee that the canister does not reply"
                ),
            },
            Err(err) => match err {
                HypervisorError::MessageRejected => Err(permission_denied_error(
                    "Requested canister rejected the message",
                )),
                err => {
                    let canonical_error = match err {
                        HypervisorError::MethodNotFound(_) => not_found_error(
                            "Attempt to execute non-existent method on the canister",
                        ),
                        HypervisorError::CalledTrap(_) => {
                            permission_denied_error("Requested canister rejected the message")
                        }
                        _ => internal_error(
                            "Requested canister failed to process the message acceptance request",
                        ),
                    };
                    Err(canonical_error)
                }
            },
        }
    }
pub fn execute_inspect_message ( & self , canister : CanisterState , sender : PrincipalId , method_name : String , method_payload : Vec < u8 > , time : Time , execution_parameters : ExecutionParameters , ) -> Result < ( ) , CanonicalError > { let method = WasmMethod :: System ( SystemMethod :: CanisterInspectMessage ) ; let memory_usage = canister . memory_usage ( self . own_subnet_type ) ; let ( execution_state , system_state , _ ) = canister . into_parts ( ) ; // Validate that the Wasm module is present. let execution_state = match execution_state { None => return Err ( not_found_error ( " " ) ) , Some ( execution_state ) => execution_state , } ; // If the Wasm module does not export the method, then this execution // succeeds as a no-op. if ! execution_state . exports_method ( & method ) { return Ok ( ( ) ) ; } let system_api = ApiType :: inspect_message ( sender , method_name , method_payload , time ) ; let log = self . log . clone ( ) ; let ( output , _output_execution_state , _system_state_accessor ) = self . execute ( system_api , system_state , memory_usage , execution_parameters , FuncRef :: Method ( method ) , execution_state , ) ; match output . wasm_result { Ok ( maybe_wasm_result ) => match maybe_wasm_result { None => Ok ( ( ) ) , Some ( _result ) => fatal ! ( log " " ) , } , Err ( err ) => match err { HypervisorError :: MessageRejected => Err ( permission_denied_error ( " " , ) ) , err => { let canonical_error = match err { HypervisorError :: MethodNotFound ( _ ) => not_found_error ( " " , ) , HypervisorError :: CalledTrap ( _ ) => { permission_denied_error ( " " ) } _ => internal_error ( " " , ) , } ; Err ( canonical_error ) } } , } }
Executes the system method `canister_inspect_message`.
Executes the system method ` canister_inspect_message ` .
&self
canister
CanisterState
sender
PrincipalId
method_name
String
method_payload
Vec<u8>
time
Time
execution_parameters
ExecutionParameters