/// Updates the RTT EMA for the node operator of `node` with the newly
/// observed `duration`.
Updates the RTT EMA for the node operator of `node` with the newly
observed `duration`.
Updates the RTT EMA for the node operator of ` node ` with the newly observed ` duration ` .
pub fn observe_roundtrip_time(&self, node: NodeId, duration: Duration) {
        // Bound durations to between 1µs and 1s (specifically avoiding 0).
        let duration_nanos = (duration.as_nanos() as u64).max(1_000).min(NANOS_PER_SEC);
        let version = self.registry.get_latest_version();
        if let Some(node_operator) =
            get_node_operator_id(&node, self.registry.as_ref(), &version, &self.log)
        {
            let metric_rtt_ema = self
                .metric_rtt_ema
                .with_label_values(&[&node_operator_to_string(&node_operator)]);
            let rtt_ema_nanos = *self
                .roundtrip_ema_nanos
                .lock()
                .unwrap()
                .entry(node_operator)
                .and_modify(|ema| *ema = (*ema * 9 + duration_nanos) / 10)
                .or_insert_with(|| duration_nanos);
            metric_rtt_ema.set(rtt_ema_nanos as f64 * 1e-9);
        } else {
            self.metric_unknown_dcop.inc();
        }
    }
pub fn observe_roundtrip_time ( & self , node : NodeId , duration : Duration ) { // Bound durations to between 1µs and 1s (specifically avoiding 0). let duration_nanos = ( duration . as_nanos ( ) as u64 ) . max ( 1_000 ) . min ( NANOS_PER_SEC ) ; let version = self . registry . get_latest_version ( ) ; if let Some ( node_operator ) = get_node_operator_id ( & node , self . registry . as_ref ( ) , & version , & self . log ) { let metric_rtt_ema = self . metric_rtt_ema . with_label_values ( & [ & node_operator_to_string ( & node_operator ) ] ) ; let rtt_ema_nanos = * self . roundtrip_ema_nanos . lock ( ) . unwrap ( ) . entry ( node_operator ) . and_modify ( | ema | * ema = ( * ema * 9 + duration_nanos ) / 10 ) . or_insert_with ( | | duration_nanos ) ; metric_rtt_ema . set ( rtt_ema_nanos as f64 * 1e-9 ) ; } else { self . metric_unknown_dcop . inc ( ) ; } }
Updates the RTT EMA for the node operator of `node` with the newly
observed `duration`.
Updates the RTT EMA for the node operator of ` node ` with the newly observed ` duration ` .
&self
node
NodeId
duration
Duration