From ede2510695345f87240ee8cf013f87065f9dac85 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 27 Jul 2022 19:16:56 +0100 Subject: [PATCH] chanmgr configuration: Initialise correctly This arranges that the ChannelsParams we have retain, and which we send to every newly created channel, actually has the right parameters, even if they're not the default. --- crates/tor-chanmgr/src/mgr/map.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/tor-chanmgr/src/mgr/map.rs b/crates/tor-chanmgr/src/mgr/map.rs index 8c7a303ce..6ff7d4766 100644 --- a/crates/tor-chanmgr/src/mgr/map.rs +++ b/crates/tor-chanmgr/src/mgr/map.rs @@ -191,7 +191,13 @@ impl ChannelState { impl ChannelMap { /// Create a new empty ChannelMap. pub(crate) fn new(config: ChannelConfig, dormancy: Dormancy) -> Self { - let channels_params = ChannelsParams::default(); + let mut channels_params = ChannelsParams::default(); + + let netdir = Err(&()); // we never have a netdir at startup + let update = parameterize(&mut channels_params, &config, dormancy, netdir) + .unwrap_or_else(|e: tor_error::Bug| panic!("bug detected on startup: {:?}", e)); + let _: Option<_> = update; // there are no channels yet, that would need to be told + ChannelMap { inner: std::sync::Mutex::new(Inner { channels: HashMap::new(), @@ -411,7 +417,6 @@ impl ChannelMap { /// /// 1. During chanmgr creation, it is called once to analyse the initial state /// and construct a corresponding ChannelsParams. -/// (TODO this doesn't happen yet.) /// /// 2. During reconfiguration. ///