MCPcopy Create free account
hub / github.com/aws/clock-bound / update

Method update

clock-bound/src/daemon/clock_sync_algorithm/selector.rs:35–60  ·  view source on GitHub ↗

Compare an input `ClockParameters` against the current best Returns `Some` if the new value is more accurate than the current best. None otherwise.

(
        &mut self,
        clock_parameters: &ClockParameters,
        source_info: SourceInfo,
    )

Source from the content-addressed store, hash-verified

33 ///
34 /// Returns `Some` if the new value is more accurate than the current best. None otherwise.
35 pub fn update(
36 &mut self,
37 clock_parameters: &ClockParameters,
38 source_info: SourceInfo,
39 ) -> Option<&ClockParameters> {
40 let Some(current) = &self.current else {
41 self.current = Some(SourceParams {
42 clock_parameters: clock_parameters.clone(),
43 source_info,
44 });
45 return self.current.as_ref().map(|sp| &sp.clock_parameters);
46 };
47
48 if current
49 .clock_parameters
50 .more_accurate_than(clock_parameters, self.max_dispersion_growth)
51 {
52 None
53 } else {
54 self.current = Some(SourceParams {
55 clock_parameters: clock_parameters.clone(),
56 source_info,
57 });
58 self.current.as_ref().map(|sp| &sp.clock_parameters)
59 }
60 }
61
62 /// Clear inner state during a disruption event
63 pub fn handle_disruption(&mut self) {

Callers 4

feed_innerMethod · 0.80
updateFunction · 0.80
handle_disruptionFunction · 0.80

Calls 2

more_accurate_thanMethod · 0.80
as_refMethod · 0.45

Tested by 2

handle_disruptionFunction · 0.64