/// Prepare a set of unvalidated ingress messages, with expiry
/// randomly distributed over the given expiry time period.
Prepare a set of unvalidated ingress messages, with expiry
randomly distributed over the given expiry time period.
Prepare a set of unvalidated ingress messages with expiry randomly distributed over the given expiry time period .
fn prepare(time_source: &dyn TimeSource, duration: Duration, num: usize) -> Vec<SignedIngress> {
    let now = time_source.get_relative_time();
    let max_expiry = now + duration;
    let mut rng = rand::thread_rng();
    (0..num)
        .map(|i| {
            let expiry = std::time::Duration::from_millis(
                rng.gen::<u64>() % ((max_expiry - now).as_millis() as u64),
            );
            SignedIngressBuilder::new()
                .method_payload(vec![0; PAYLOAD_SIZE])
                .nonce(i as u64)
                .expiry_time(now + expiry)
                .build()
        })
        .collect::<Vec<_>>()
}
fn prepare ( time_source : & dyn TimeSource , duration : Duration , num : usize ) -> Vec < SignedIngress > { let now = time_source . get_relative_time ( ) ; let max_expiry = now + duration ; let mut rng = rand :: thread_rng ( ) ; ( 0 .. num ) . map ( | i | { let expiry = std :: time :: Duration :: from_millis ( rng . gen :: < u64 > ( ) % ( ( max_expiry - now ) . as_millis ( ) as u64 ) , ) ; SignedIngressBuilder :: new ( ) . method_payload ( vec ! [ 0 PAYLOAD_SIZE ] ) . nonce ( i as u64 ) . expiry_time ( now + expiry ) . build ( ) } ) . collect :: < Vec < _ > > ( ) }
Prepare a set of unvalidated ingress messages, with expiry
randomly distributed over the given expiry time period.
Prepare a set of unvalidated ingress messages with expiry randomly distributed over the given expiry time period .
time_source
&dyn TimeSource
duration
Duration
num
usize