/// Asks the canister if it is willing to accept the provided ingress
/// message.
Asks the canister if it is willing to accept the provided ingress
message.
Asks the canister if it is willing to accept the provided ingress message .
pub fn should_accept_ingress_message(
        &self,
        state: Arc<ReplicatedState>,
        provisional_whitelist: &ProvisionalWhitelist,
        ingress: &SignedIngressContent,
        execution_mode: ExecutionMode,
    ) -> Result<(), CanonicalError> {
        // A first-pass check on the canister's balance to prevent needless gossiping
        // if the canister's balance is too low. A more rigorous check happens later
        // in the ingress selector.
        {
            let induction_cost = self
                .cycles_account_manager
                .ingress_induction_cost(ingress)
                .map_err(|_| permission_denied_error("Requested canister rejected the message"))?;
            if let IngressInductionCost::Fee { payer, cost } = induction_cost {
                match state.canister_state(&payer) {
                    Some(canister) => {
                        if let Err(err) = self.cycles_account_manager.can_withdraw_cycles(
                            &canister.system_state,
                            cost,
                            canister.memory_usage(self.own_subnet_type),
                            canister.scheduler_state.compute_allocation,
                        ) {
                            return Err(permission_denied_error(&err.to_string()));
                        }
                    }
                    None => {
                        return Err(not_found_error("Requested canister does not exist"));
                    }
                }
            }
        }
        let canister_id = ingress.canister_id();
        let sender = ingress.sender();
        let method_name = ingress.method_name().to_string();
        let payload = ingress.arg();
        if is_subnet_message(ingress, self.own_subnet_id) {
            self.canister_manager.should_accept_ingress_message(
                state,
                provisional_whitelist,
                sender,
                &method_name,
                payload,
            )
        } else {
            match state.canister_state(&canister_id) {
                Some(canister) => {
                    // Letting the canister grow arbitrarily when executing the
                    // query is fine as we do not persist state modifications.
                    let subnet_available_memory =
                        SubnetAvailableMemory::new(self.config.subnet_memory_capacity.get() as i64);
                    let execution_parameters = self.execution_parameters(
                        canister,
                        self.config.max_instructions_for_message_acceptance_calls,
                        subnet_available_memory,
                        execution_mode,
                    );
                    self.hypervisor.execute_inspect_message(
                        canister.clone(),
                        sender.get(),
                        method_name,
                        payload.to_vec(),
                        state.time(),
                        execution_parameters,
                    )
                }
                None => Err(not_found_error("Requested canister does not exist")),
            }
        }
    }
pub fn should_accept_ingress_message ( & self , state : Arc < ReplicatedState > , provisional_whitelist : & ProvisionalWhitelist , ingress : & SignedIngressContent , execution_mode : ExecutionMode , ) -> Result < ( ) , CanonicalError > { // A first-pass check on the canister's balance to prevent needless gossiping // if the canister's balance is too low. A more rigorous check happens later // in the ingress selector. { let induction_cost = self . cycles_account_manager . ingress_induction_cost ( ingress ) . map_err ( | _ | permission_denied_error ( " " ) ) ? ; if let IngressInductionCost :: Fee { payer , cost } = induction_cost { match state . canister_state ( & payer ) { Some ( canister ) => { if let Err ( err ) = self . cycles_account_manager . can_withdraw_cycles ( & canister . system_state , cost , canister . memory_usage ( self . own_subnet_type ) , canister . scheduler_state . compute_allocation , ) { return Err ( permission_denied_error ( & err . to_string ( ) ) ) ; } } None => { return Err ( not_found_error ( " " ) ) ; } } } } let canister_id = ingress . canister_id ( ) ; let sender = ingress . sender ( ) ; let method_name = ingress . method_name ( ) . to_string ( ) ; let payload = ingress . arg ( ) ; if is_subnet_message ( ingress , self . own_subnet_id ) { self . canister_manager . should_accept_ingress_message ( state , provisional_whitelist , sender , & method_name , payload , ) } else { match state . canister_state ( & canister_id ) { Some ( canister ) => { // Letting the canister grow arbitrarily when executing the // query is fine as we do not persist state modifications. let subnet_available_memory = SubnetAvailableMemory :: new ( self . config . subnet_memory_capacity . get ( ) as i64 ) ; let execution_parameters = self . execution_parameters ( canister , self . config . max_instructions_for_message_acceptance_calls , subnet_available_memory , execution_mode , ) ; self . hypervisor . execute_inspect_message ( canister . clone ( ) , sender . get ( ) , method_name , payload . to_vec ( ) , state . time ( ) , execution_parameters , ) } None => Err ( not_found_error ( " " ) ) , } } }
Asks the canister if it is willing to accept the provided ingress
message.
Asks the canister if it is willing to accept the provided ingress message .
&self
state
Arc<ReplicatedState>
provisional_whitelist
&ProvisionalWhitelist
ingress
&SignedIngressContent
execution_mode
ExecutionMode