From 837c7d717b09ca2639287ad168ccadcdb7063835 Mon Sep 17 00:00:00 2001 From: Nick Mathewson <nickm@torproject.org> Date: Fri, 11 Mar 2022 11:34:51 -0500 Subject: [PATCH] Follow-up from arti!318 Make update_config only conditionally exported; add semver-status update. --- crates/tor-dirmgr/src/config.rs | 11 ++++++++++- crates/tor-dirmgr/src/lib.rs | 2 +- doc/semver_status.md | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/tor-dirmgr/src/config.rs b/crates/tor-dirmgr/src/config.rs index 64ca10e850..b082ed716e 100644 --- a/crates/tor-dirmgr/src/config.rs +++ b/crates/tor-dirmgr/src/config.rs @@ -267,7 +267,7 @@ impl DirMgrConfig { /// `self` are replaced with those from `new_config`. /// /// Any fields which aren't allowed to change at runtime are copied from self. - pub fn update_config(&self, new_config: &DirMgrConfig) -> DirMgrConfig { + pub(crate) fn update_from_config(&self, new_config: &DirMgrConfig) -> DirMgrConfig { DirMgrConfig { cache_path: self.cache_path.clone(), network_config: NetworkConfig { @@ -278,6 +278,15 @@ impl DirMgrConfig { override_net_params: new_config.override_net_params.clone(), } } + + /// Construct a new configuration object where all replaceable fields in + /// `self` are replaced with those from `new_config`. + /// + /// Any fields which aren't allowed to change at runtime are copied from self. + #[cfg(feature = "experimental-api")] + pub fn update_config(&self, new_config: &DirMgrConfig) -> DirMgrConfig { + self.update_from_config(new_config) + } } impl DownloadScheduleConfig { diff --git a/crates/tor-dirmgr/src/lib.rs b/crates/tor-dirmgr/src/lib.rs index a0d6f5c47c..9a63f21fd1 100644 --- a/crates/tor-dirmgr/src/lib.rs +++ b/crates/tor-dirmgr/src/lib.rs @@ -620,7 +620,7 @@ impl<R: Runtime> DirMgr<R> { let params_changed = new_config.override_net_params() != config.override_net_params(); self.config - .map_and_replace(|cfg| cfg.update_config(new_config)); + .map_and_replace(|cfg| cfg.update_from_config(new_config)); if params_changed { let _ignore_err = self.netdir.mutate(|netdir| { diff --git a/doc/semver_status.md b/doc/semver_status.md index ad348cf268..61cc77f734 100644 --- a/doc/semver_status.md +++ b/doc/semver_status.md @@ -35,4 +35,13 @@ arti-client: api-break (experimental only): changed circmgr() and dirmgr() to return &Arc, not Arc. +tor-dirmgr: + + new-api: DirMgrConfig object now has accessors. + +tor-netdoc: + + new-api (experimental only): Can modify the set of relays in an unverified + consensus. + -- GitLab