circmgr: re-export clock skew estimates.

This commit is contained in:
Nick Mathewson 2022-04-11 15:18:59 -04:00
parent 5f5cbdc08e
commit 72f00daf12
3 changed files with 16 additions and 0 deletions

View File

@ -77,6 +77,7 @@ mod usage;
pub use err::Error;
pub use isolation::IsolationToken;
use tor_guardmgr::fallback::FallbackList;
pub use tor_guardmgr::{ClockSkewEvents, SkewEstimate};
pub use usage::{TargetPort, TargetPorts};
pub use config::{
@ -722,6 +723,17 @@ impl<R: Runtime> CircMgr<R> {
external_activity,
);
}
/// Return a stream of events about our estimated clock skew; these events
/// are `None` when we don't have enough information to make an estimate,
/// and `Some(`[`SkewEstiamte`]`)` otherwise.
///
/// Note that this stream can be lossy: if the estimate changes more than
/// one before you read from the stream, you might only get the most recent
/// update.
pub fn skew_events(&self) -> ClockSkewEvents {
self.mgr.peek_builder().guardmgr().skew_events()
}
}
impl<R: Runtime> Drop for CircMgr<R> {

View File

@ -12,6 +12,8 @@ use tor_basic_utils::skip_fmt;
///
/// Note that this stream can be lossy: if multiple events trigger before you
/// read from it, you will only get the most recent estimate.
//
// SEMVER NOTE: this type is re-exported from tor-circmgr.
#[derive(Clone, Educe)]
#[educe(Debug)]
pub struct ClockSkewEvents {

View File

@ -29,6 +29,8 @@ impl SkewObservation {
}
/// An estimate of how skewed our clock is, plus a summary of why we think so.
//
// SEMVER NOTE: this type is re-exported from tor-circmgr.
#[derive(Clone, Debug)]
pub struct SkewEstimate {
/// Our best guess for the magnitude of the skew.