pub fn should_accept_ingress_message(
        &self,
        state: Arc<ReplicatedState>,
        provisional_whitelist: &ProvisionalWhitelist,
        ingress: &SignedIngressContent,
    ) -> Result<(), MessageAcceptanceError> {
        // 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(|_| MessageAcceptanceError::CanisterRejected)?;

            if let IngressInductionCost::Fee { payer, cost } = induction_cost {
                match state.canister_state(&payer) {
                    Some(canister) => {
                        if cost
                            > self
                                .cycles_account_manager
                                .cycles_balance_above_storage_reserve(
                                    &canister.system_state,
                                    canister.memory_usage(),
                                    canister.scheduler_state.compute_allocation,
                                )
                        {
                            return Err(MessageAcceptanceError::CanisterOutOfCycles);
                        }
                    }
                    None => {
                        return Err(MessageAcceptanceError::CanisterNotFound);
                    }
                }
            }
        }

        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) => self.hypervisor.execute_inspect_message(
                    canister.clone(),
                    sender.get(),
                    method_name,
                    payload.to_vec(),
                    self.config.max_instructions_for_message_acceptance_calls,
                    state.time(),
                ),
                None => Err(MessageAcceptanceError::CanisterNotFound),
            }
        }
    }
/// 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,
    ) -> Result<(), MessageAcceptanceError> {
        // 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(|_| MessageAcceptanceError::CanisterRejected)?;
            if let IngressInductionCost::Fee { payer, cost } = induction_cost {
                match state.canister_state(&payer) {
                    Some(canister) => {
                        if cost
                            > self
                                .cycles_account_manager
                                .cycles_balance_above_storage_reserve(
                                    &canister.system_state,
                                    canister.memory_usage(),
                                    canister.scheduler_state.compute_allocation,
                                )
                        {
                            return Err(MessageAcceptanceError::CanisterOutOfCycles);
                        }
                    }
                    None => {
                        return Err(MessageAcceptanceError::CanisterNotFound);
                    }
                }
            }
        }
        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) => self.hypervisor.execute_inspect_message(
                    canister.clone(),
                    sender.get(),
                    method_name,
                    payload.to_vec(),
                    self.config.max_instructions_for_message_acceptance_calls,
                    state.time(),
                ),
                None => Err(MessageAcceptanceError::CanisterNotFound),
            }
        }
    }
pub fn should_accept_ingress_message ( & self , state : Arc < ReplicatedState > , provisional_whitelist : & ProvisionalWhitelist , ingress : & SignedIngressContent , ) -> Result < ( ) , MessageAcceptanceError > { // 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 ( | _ | MessageAcceptanceError :: CanisterRejected ) ? ; if let IngressInductionCost :: Fee { payer , cost } = induction_cost { match state . canister_state ( & payer ) { Some ( canister ) => { if cost > self . cycles_account_manager . cycles_balance_above_storage_reserve ( & canister . system_state , canister . memory_usage ( ) , canister . scheduler_state . compute_allocation , ) { return Err ( MessageAcceptanceError :: CanisterOutOfCycles ) ; } } None => { return Err ( MessageAcceptanceError :: CanisterNotFound ) ; } } } } 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 ) => self . hypervisor . execute_inspect_message ( canister . clone ( ) , sender . get ( ) , method_name , payload . to_vec ( ) , self . config . max_instructions_for_message_acceptance_calls , state . time ( ) , ) , None => Err ( MessageAcceptanceError :: CanisterNotFound ) , } } }
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
&self
state
Arc<ReplicatedState>
provisional_whitelist
&ProvisionalWhitelist
ingress
&SignedIngressContent