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,
)
| 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) { |