macro_rules! next_poll_delay {
($reached_all_peers:expr $(,)?) => { ... };
}Expand description
Return the delay before polling peers again for their supported module consensus versions.
After a restart, the first poll can run before peers’ API servers bind. Retry soon if a round fails to reach all peers, so activation need not wait for the full interval. Keep polling unreachable peers at the short interval, a few requests per minute.
Like is_running_in_test_env!, this macro checks for unit tests in the
calling crate. It evaluates its argument exactly once, including in test
mode.
use std::time::Duration;
use fedimint_core::envs::{is_running_in_test_env, next_poll_delay};
assert!(!cfg!(test));
let in_test_env = is_running_in_test_env!();
assert_eq!(
next_poll_delay!(true),
Duration::from_secs(if in_test_env { 5 } else { 600 }),
);
assert_eq!(
next_poll_delay!(false),
Duration::from_secs(if in_test_env { 5 } else { 30 }),
);