aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/skew.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/swarm/skew.rs b/src/swarm/skew.rs
index af11e5e..f5d9858 100644
--- a/src/swarm/skew.rs
+++ b/src/swarm/skew.rs
@@ -34,6 +34,8 @@ pub(crate) struct Skew {
/// Whether ours is off: more than half of them differ from it beyond the limit,
/// the same way. Never with a limit of 0.
pub(crate) off: bool,
+ /// The limit (`--clock-skew-warn`).
+ pub(crate) limit_ms: u64,
}
/// Ours against the peers' clocks `offsets` (each ahead of ours), with `limit`.
@@ -59,6 +61,7 @@ pub(crate) fn of(offsets: &[ClockOffset], limit: Duration) -> Skew {
behind,
ahead,
off: limit_ms > 0 && (ahead * 2 > peers || behind * 2 > peers),
+ limit_ms,
}
}
@@ -143,6 +146,7 @@ mod tests {
// A limit of 0: never.
assert!(!of(&[offset(60_000, 10)], Duration::ZERO).off);
// No peers: nothing known.
- assert_eq!(of(&[], limit), Skew::default());
+ let none = of(&[], limit);
+ assert_eq!((none.peers, none.offset_ms, none.off), (0, None, false));
}
}