Skip to content

Commit

Permalink
Move channel config load after watch_channel
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 9, 2024
1 parent 511de4b commit 8e723c8
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,36 +403,6 @@ impl<S: MutinyStorage> NodeBuilder<S> {
let channel_manager: Arc<PhantomChannelManager<S>> =
Arc::new(read_channel_manager.channel_manager);

// Check all existing channels against default configs.
// If we have default config changes, those should apply
// to all existing and new channels.
let default_config = default_user_config().channel_config;
for channel in channel_manager.list_channels() {
// unwrap is safe after LDK.0.0.109
if channel.config.unwrap() != default_config {
match channel_manager.update_channel_config(
&channel.counterparty.node_id,
&[channel.channel_id],
&default_config,
) {
Ok(_) => {
log_debug!(
logger,
"changed default config for channel: {}",
channel.channel_id.to_hex()
)
}
Err(e) => {
log_error!(
logger,
"error changing default config for channel: {} - {e:?}",
channel.channel_id.to_hex()
)
}
};
}
}

log_info!(logger, "creating lsp client");
let lsp_config: Option<LspConfig> = match node_index.lsp {
None => {
Expand Down Expand Up @@ -621,6 +591,36 @@ impl<S: MutinyStorage> NodeBuilder<S> {
}
}

// Check all existing channels against default configs.
// If we have default config changes, those should apply
// to all existing and new channels.
let default_config = default_user_config().channel_config;
for channel in channel_manager.list_channels() {
// unwrap is safe after LDK.0.0.109
if channel.config.unwrap() != default_config {
match channel_manager.update_channel_config(
&channel.counterparty.node_id,
&[channel.channel_id],
&default_config,
) {
Ok(_) => {
log_debug!(
logger,
"changed default config for channel: {}",
channel.channel_id.to_hex()
)
}
Err(e) => {
log_error!(
logger,
"error changing default config for channel: {} - {e:?}",
channel.channel_id.to_hex()
)
}
};
}
}

let background_persister = persister.clone();
let background_event_handler = event_handler.clone();
let background_processor_logger = logger.clone();
Expand Down

0 comments on commit 8e723c8

Please sign in to comment.