fn execute_ingress_message(
    message_routing: &dyn MessageRouting,
    msg: SignedIngress,
    msg_id: &MessageId,
    ingress_history: &dyn IngressHistoryReader,
) -> Result<WasmResult, UserError> {
    let mut batch = build_batch(message_routing, vec![msg]);

    let time_start = Instant::now();

    while Instant::now().duration_since(time_start) < Duration::from_secs(30) {
        // In the first batch we try to send the ingress message itself. If it fails, we
        // repeat with the same batch.
        //
        // After the batch with a message is delivered, we keep submitting work to
        // message routing in the form of empty batches till the ingress message has
        // finished executing. This is necessary to get message routing to process
        // potential inter-canister messages that the ingress message may have
        // triggered.
        if message_routing.deliver_batch(batch.clone()).is_ok() {
            batch = build_batch(message_routing, vec![])
        }

        let ingress_result = (ingress_history.get_latest_status())(msg_id);
        match ingress_result {
            IngressStatus::Completed { result, .. } => return Ok(result),
            IngressStatus::Failed { error, .. } => return Err(error),
            IngressStatus::Received { .. }
            | IngressStatus::Processing { .. }
            | IngressStatus::Unknown => (),
        }
    }
    panic!("Ingress message did not finish executing within 30 seconds");
}
/// Block till the given ingress message has finished executing and
/// then return the result.  To ensure that this function does not
/// block forever (in case of bugs), this function will panic if the
/// process is not finished in some amount of time.
Block till the given ingress message has finished executing and
then return the result.  To ensure that this function does not
block forever (in case of bugs), this function will panic if the
process is not finished in some amount of time.
Block till the given ingress message has finished executing and then return the result . To ensure that this function does not block forever ( in case of bugs ) this function will panic if the process is not finished in some amount of time .
fn execute_ingress_message(
    message_routing: &dyn MessageRouting,
    msg: SignedIngress,
    msg_id: &MessageId,
    ingress_history: &dyn IngressHistoryReader,
) -> Result<WasmResult, UserError> {
    let mut batch = build_batch(message_routing, vec![msg]);
    let time_start = Instant::now();
    while Instant::now().duration_since(time_start) < Duration::from_secs(30) {
        // In the first batch we try to send the ingress message itself. If it fails, we
        // repeat with the same batch.
        //
        // After the batch with a message is delivered, we keep submitting work to
        // message routing in the form of empty batches till the ingress message has
        // finished executing. This is necessary to get message routing to process
        // potential inter-canister messages that the ingress message may have
        // triggered.
        if message_routing.deliver_batch(batch.clone()).is_ok() {
            batch = build_batch(message_routing, vec![])
        }
        let ingress_result = (ingress_history.get_latest_status())(msg_id);
        match ingress_result {
            IngressStatus::Completed { result, .. } => return Ok(result),
            IngressStatus::Failed { error, .. } => return Err(error),
            IngressStatus::Received { .. }
            | IngressStatus::Processing { .. }
            | IngressStatus::Unknown => (),
        }
    }
    panic!("Ingress message did not finish executing within 30 seconds");
}
fn execute_ingress_message ( message_routing : & dyn MessageRouting , msg : SignedIngress , msg_id : & MessageId , ingress_history : & dyn IngressHistoryReader , ) -> Result < WasmResult , UserError > { let mut batch = build_batch ( message_routing , vec ! [ msg ] ) ; let time_start = Instant :: now ( ) ; while Instant :: now ( ) . duration_since ( time_start ) < Duration :: from_secs ( 30 ) { // In the first batch we try to send the ingress message itself. If it fails, we // repeat with the same batch. // // After the batch with a message is delivered, we keep submitting work to // message routing in the form of empty batches till the ingress message has // finished executing. This is necessary to get message routing to process // potential inter-canister messages that the ingress message may have // triggered. if message_routing . deliver_batch ( batch . clone ( ) ) . is_ok ( ) { batch = build_batch ( message_routing , vec ! [ ] ) } let ingress_result = ( ingress_history . get_latest_status ( ) ) ( msg_id ) ; match ingress_result { IngressStatus :: Completed { result , .. } => return Ok ( result ) , IngressStatus :: Failed { error , .. } => return Err ( error ) , IngressStatus :: Received { .. } | IngressStatus :: Processing { .. } | IngressStatus :: Unknown => ( ) , } } panic ! ( " " ) ; }
Block till the given ingress message has finished executing and
then return the result.
Block till the given ingress message has finished executing and then return the result .
message_routing
&dyn MessageRouting
msg
SignedIngress
msg_id
&MessageId
ingress_history
&dyn IngressHistoryReader
message_routing
&dyn MessageRouting
msg
SignedIngress
msg_id
&MessageId
ingress_history
&dyn IngressHistoryReader