From c1cb16be7894885ec5066dafc25b92f348ced11a Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 05:26:34 +0100 Subject: tree latency measured --- src/transport/sim.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/transport') diff --git a/src/transport/sim.rs b/src/transport/sim.rs index d218d5c..12f3885 100644 --- a/src/transport/sim.rs +++ b/src/transport/sim.rs @@ -170,6 +170,16 @@ impl SimNet { .insert((from.to_owned(), to.to_owned()), params); } + /// The mean delay from `from` to `to` (one way): its link's, or the default's. + pub(crate) fn mean_delay(&self, from: &str, to: &str) -> Duration { + let inner = self.lock(); + let link = inner + .links + .get(&(from.to_owned(), to.to_owned())) + .unwrap_or(&inner.default_link); + (link.delay.0 + link.delay.1) / 2 + } + /// Everything to and from `id` is lost until [`bring_up`](Self::bring_up), including /// messages already on their way. The node itself keeps running. pub(crate) fn take_down(&self, id: &str) { -- cgit v1.3.1