Timing: Add `gossip_interval` field as a Duration
@@ -14,15 +14,16 @@ const GOSSIP_INTERVAL_DEFAULT_MS: u64 = 1000;
/// just for your own sanity - this is 3 days.
const DEPARTURE_TIMEOUT_DEFAULT_MS: u64 = 259_200_000;
-/// The timing of the outbound threads.
+/// Collects important timing durations and timekeeping activities for
+/// the underlying gossip protocols.
#[derive(Debug, Clone)]
pub struct Timing {
ping: Duration,
pingreq: Duration,
confirm: Duration,
departure: Duration,
- gossip_interval_ms: u64,
+ gossip_interval: Duration,
swim_probe_interval: Duration,
}
@@ -35,15 +36,12 @@ impl Default for Timing {
pingreq: Duration::from_millis(PINGREQ_TIMING_DEFAULT_MS),
confirm: Duration::from_millis(confirm_ms),
departure: Duration::from_millis(DEPARTURE_TIMEOUT_DEFAULT_MS),
- gossip_interval_ms: GOSSIP_INTERVAL_DEFAULT_MS,
+ gossip_interval: Duration::from_millis(GOSSIP_INTERVAL_DEFAULT_MS),
swim_probe_interval: Duration::from_millis(swim_interval_ms), }
}
}
impl Timing {
- /// How long a gossip period should last.
- fn gossip_interval(&self) -> Duration { Duration::from_millis(self.gossip_interval_ms) }
-
/// How long a ping has to timeout.
pub fn ping(&self) -> Duration { self.ping }
@@ -61,7 +59,7 @@ impl Timing {
/// If the amount of time since `starting_point` is less than a
/// gossip interval, sleep for the remainder of that gossip interval.
pub fn sleep_for_remaining_gossip_interval(&self, starting_point: Instant) {
- maybe_sleep(starting_point, self.gossip_interval())
+ maybe_sleep(starting_point, self.gossip_interval)
}
/// If the amount of time since `starting_point` is less than a
