From 7b19dfcb9a3eb3424bad0b95c13dac2fdebafd9c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 06:55:20 +0100 Subject: dashboard: add clocks --- src/swarm/skew.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/swarm') 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)); } } -- cgit v1.3.1