diff options
| author | tv <tv@krebsco.de> | 2026-10-31 06:55:20 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 06:55:20 +0100 |
| commit | 7b19dfcb9a3eb3424bad0b95c13dac2fdebafd9c (patch) | |
| tree | e9763b29a851e7eb9cf9615a1cbbe576560048ff /src/swarm | |
| parent | b67c08db206494ded718f17ff4afd1ec4c0b59a4 (diff) | |
dashboard: add clocks
Diffstat (limited to 'src/swarm')
| -rw-r--r-- | src/swarm/skew.rs | 6 |
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)); } } |
