Loading crates/tor-dirmgr/semver.md +1 −1 Original line number Diff line number Diff line BREAKING: Changes to error variants. BREAKING: Renamed DirSkewTolerance to DirTolerance. BREAKING: Removed `netdir` method from DirMgr, and make `opt_netdir` private. BREAKING: Removed `netdir` and `opt_netdir` methods from DirMgr. crates/tor-dirmgr/src/bootstrap.rs +3 −3 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ use once_cell::sync::Lazy; #[cfg(test)] use std::sync::Mutex; use tor_circmgr::{CircMgr, DirInfo}; use tor_netdir::NetDir; use tor_netdir::{NetDir, NetDirProvider as _}; use tor_netdoc::doc::netstatus::ConsensusFlavor; /// Given a Result<()>, exit the current function if it is anything other than Loading Loading @@ -308,8 +308,8 @@ async fn fetch_multiple<R: Runtime>( } let circmgr = dirmgr.circmgr()?; // TODO(eta): Maybe don't hold this netdir for so long? let netdir = dirmgr.opt_netdir(); // Only use timely directories for bootstrapping directories; otherwise, we'll try fallbacks. let netdir = dirmgr.netdir(tor_netdir::Timeliness::Timely).ok(); // TODO: instead of waiting for all the queries to finish, we // could stream the responses back or something. Loading crates/tor-dirmgr/src/lib.rs +5 −8 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ pub trait DirProvider: NetDirProvider { impl<R: Runtime> NetDirProvider for DirMgr<R> { fn netdir(&self, timeliness: Timeliness) -> tor_netdir::Result<Arc<NetDir>> { use tor_netdir::Error as NetDirError; let netdir = self.opt_netdir().ok_or(NetDirError::NoInfo)?; let netdir = self.netdir.get().ok_or(NetDirError::NoInfo)?; let lifetime = match timeliness { Timeliness::Strict => netdir.lifetime().clone(), Timeliness::Timely => self Loading Loading @@ -317,7 +317,9 @@ impl<R: Runtime> DirMgr<R> { // TODO: add some way to return a directory that isn't up-to-date let _success = dirmgr.load_directory(AttemptId::next()).await?; dirmgr.opt_netdir().ok_or(Error::DirectoryNotPresent) dirmgr .netdir(Timeliness::Timely) .map_err(|_| Error::DirectoryNotPresent) } /// Return a current netdir, either loading it or bootstrapping it Loading Loading @@ -859,11 +861,6 @@ impl<R: Runtime> DirMgr<R> { Ok(self.netdir.get().is_some()) } /// Return an Arc handle to our latest directory, if we have one. fn opt_netdir(&self) -> Option<Arc<NetDir>> { self.netdir.get() } /// Return a new asynchronous stream that will receive notification /// whenever the consensus has changed. /// Loading Loading @@ -1090,7 +1087,7 @@ mod test { let (_tempdir, mgr) = new_mgr(rt); assert!(mgr.circmgr().is_err()); assert!(mgr.opt_netdir().is_none()); assert!(mgr.netdir(Timeliness::Unchecked).is_err()); }); } Loading Loading
crates/tor-dirmgr/semver.md +1 −1 Original line number Diff line number Diff line BREAKING: Changes to error variants. BREAKING: Renamed DirSkewTolerance to DirTolerance. BREAKING: Removed `netdir` method from DirMgr, and make `opt_netdir` private. BREAKING: Removed `netdir` and `opt_netdir` methods from DirMgr.
crates/tor-dirmgr/src/bootstrap.rs +3 −3 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ use once_cell::sync::Lazy; #[cfg(test)] use std::sync::Mutex; use tor_circmgr::{CircMgr, DirInfo}; use tor_netdir::NetDir; use tor_netdir::{NetDir, NetDirProvider as _}; use tor_netdoc::doc::netstatus::ConsensusFlavor; /// Given a Result<()>, exit the current function if it is anything other than Loading Loading @@ -308,8 +308,8 @@ async fn fetch_multiple<R: Runtime>( } let circmgr = dirmgr.circmgr()?; // TODO(eta): Maybe don't hold this netdir for so long? let netdir = dirmgr.opt_netdir(); // Only use timely directories for bootstrapping directories; otherwise, we'll try fallbacks. let netdir = dirmgr.netdir(tor_netdir::Timeliness::Timely).ok(); // TODO: instead of waiting for all the queries to finish, we // could stream the responses back or something. Loading
crates/tor-dirmgr/src/lib.rs +5 −8 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ pub trait DirProvider: NetDirProvider { impl<R: Runtime> NetDirProvider for DirMgr<R> { fn netdir(&self, timeliness: Timeliness) -> tor_netdir::Result<Arc<NetDir>> { use tor_netdir::Error as NetDirError; let netdir = self.opt_netdir().ok_or(NetDirError::NoInfo)?; let netdir = self.netdir.get().ok_or(NetDirError::NoInfo)?; let lifetime = match timeliness { Timeliness::Strict => netdir.lifetime().clone(), Timeliness::Timely => self Loading Loading @@ -317,7 +317,9 @@ impl<R: Runtime> DirMgr<R> { // TODO: add some way to return a directory that isn't up-to-date let _success = dirmgr.load_directory(AttemptId::next()).await?; dirmgr.opt_netdir().ok_or(Error::DirectoryNotPresent) dirmgr .netdir(Timeliness::Timely) .map_err(|_| Error::DirectoryNotPresent) } /// Return a current netdir, either loading it or bootstrapping it Loading Loading @@ -859,11 +861,6 @@ impl<R: Runtime> DirMgr<R> { Ok(self.netdir.get().is_some()) } /// Return an Arc handle to our latest directory, if we have one. fn opt_netdir(&self) -> Option<Arc<NetDir>> { self.netdir.get() } /// Return a new asynchronous stream that will receive notification /// whenever the consensus has changed. /// Loading Loading @@ -1090,7 +1087,7 @@ mod test { let (_tempdir, mgr) = new_mgr(rt); assert!(mgr.circmgr().is_err()); assert!(mgr.opt_netdir().is_none()); assert!(mgr.netdir(Timeliness::Unchecked).is_err()); }); } Loading