From d840bbbf64bf9924745b3906947ea480ca80c228 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 8 Sep 2020 14:01:26 -0400 Subject: [PATCH] TimerangeBound: add functions to extend the tolerances (This seems much cleaner than baking extra tolerances into the "true" validity intervals") --- tor-checkable/src/timed.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tor-checkable/src/timed.rs b/tor-checkable/src/timed.rs index 168d10e10..68a7f9e68 100644 --- a/tor-checkable/src/timed.rs +++ b/tor-checkable/src/timed.rs @@ -54,6 +54,19 @@ impl TimerangeBound { let end = unwrap_bound(range.end_bound()); Self { obj, start, end } } + + /// Adjust this time-range bound to tolerate an expiration time farther + /// in the future. + pub fn extend_tolerance(self, d: time::Duration) -> Self { + let end = self.end.map(|t| t + d); + Self { end, ..self } + } + /// Adjust this time-range bound to tolerate an initial validity + /// time farther in the past. + pub fn extend_pre_tolerance(self, d: time::Duration) -> Self { + let start = self.start.map(|t| t - d); + Self { start, ..self } + } } impl crate::Timebound for TimerangeBound {