chanmgr: Postpone padding parameters computation

Now that we make an extract from the incoming NetDir, we can move the
padding parameters computation to after we take the lock.

This will be necessary for it to be able to depend on the config and
dormancy, records of which are protected by the chanmgr lock.
This commit is contained in:
Ian Jackson 2022-07-27 20:35:13 +01:00
parent eb9b164fd8
commit 156d42ab80
1 changed files with 12 additions and 12 deletions

View File

@ -344,6 +344,18 @@ impl<C: AbstractChannel> ChannelMap<C> {
nde
};
let mut inner = self
.inner
.lock()
.map_err(|_| internal!("poisonned channel manager"))?;
if let Some(new_config) = new_config {
inner.config = new_config.clone();
}
if let Some(new_dormancy) = new_dormancy {
inner.dormancy = new_dormancy;
}
let padding_parameters = {
let mut p = PaddingParametersBuilder::default();
update_padding_parameters_from_netdir(&mut p, &netdir).unwrap_or_else(|e| {
@ -359,18 +371,6 @@ impl<C: AbstractChannel> ChannelMap<C> {
p
};
let mut inner = self
.inner
.lock()
.map_err(|_| internal!("poisonned channel manager"))?;
if let Some(new_config) = new_config {
inner.config = new_config.clone();
}
if let Some(new_dormancy) = new_dormancy {
inner.dormancy = new_dormancy;
}
let update = inner
.channels_params
.start_update()