/// To have deterministic output, it is necessary in some cases to wait a number
/// of batches before executing the next message.
///
/// Example:
/// User --Ingress--> BA --Inter-canister-request--> Hotel 1
///                      --Inter-canister-request--> Hotel 2
///
/// The user sends an Ingress message to the booking agent (BA) and waits for
/// its completion. The booking agent may respond to the Ingress message after
/// receiving responses to a subset of requests it sent out. The user thinks the
/// request is done and starts executing the next message.
///
/// If processing of remaining messages produces an output, the order in which
/// output messages are produced by executing the query message in Hotel 2 and
/// the next message in Hotel 1 leads to non-determinism.
///
/// Waiting for some extra batches via this method helps avoid this problem.
///
/// This is a temporary measure until DFN-1269 is resolved. In that ticket, we
/// will actually try to wait until all messages have been executed.
To have deterministic output, it is necessary in some cases to wait a number
of batches before executing the next message.



The user sends an Ingress message to the booking agent (BA) and waits for
its completion. The booking agent may respond to the Ingress message after
receiving responses to a subset of requests it sent out. The user thinks the
request is done and starts executing the next message.

If processing of remaining messages produces an output, the order in which
output messages are produced by executing the query message in Hotel 2 and
the next message in Hotel 1 leads to non-determinism.

Waiting for some extra batches via this method helps avoid this problem.

This is a temporary measure until DFN-1269 is resolved. In that ticket, we
will actually try to wait until all messages have been executed.
To have deterministic output it is necessary in some cases to wait a number of batches before executing the next message . The user sends an Ingress message to the booking agent ( BA ) and waits for its completion . The booking agent may respond to the Ingress message after receiving responses to a subset of requests it sent out . The user thinks the request is done and starts executing the next message . If processing of remaining messages produces an output the order in which output messages are produced by executing the query message in Hotel 2 and the next message in Hotel 1 leads to non - determinism . Waiting for some extra batches via this method helps avoid this problem . This is a temporary measure until DFN - 1269 is resolved . In that ticket we will actually try to wait until all messages have been executed .
fn wait_extra_batches(message_routing: &dyn MessageRouting, extra_batches: u64) {
    for _ in 0..extra_batches {
        loop {
            let batch = build_batch(message_routing, vec![]);
            let ok = message_routing.deliver_batch(batch).is_ok();
            sleep(WAIT_PER_BATCH);
            if ok {
                break;
            };
        }
    }
}
fn wait_extra_batches ( message_routing : & dyn MessageRouting , extra_batches : u64 ) { for _ in 0 .. extra_batches { loop { let batch = build_batch ( message_routing , vec ! [ ] ) ; let ok = message_routing . deliver_batch ( batch ) . is_ok ( ) ; sleep ( WAIT_PER_BATCH ) ; if ok { break ; } ; } } }
To have deterministic output, it is necessary in some cases to wait a number
of batches before executing the next message.
To have deterministic output it is necessary in some cases to wait a number of batches before executing the next message .
message_routing
&dyn MessageRouting
extra_batches
u64