Skip to content

Commit

Permalink
f dedup channel update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dunxen committed Aug 26, 2023
1 parent 9480930 commit c67d033
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3663,24 +3663,14 @@ where
if !channel_phase.context_mut().update_config(&config) {
continue;
}
match channel_phase {
ChannelPhase::Funded(channel) => {
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
node_id: channel.context.get_counterparty_node_id(),
msg,
});
}
},
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => {
let context = channel_phase.context_mut();
let mut config = context.config();
config.apply(config_update);
// We update the config, but we MUST NOT broadcast a `channel_update` before `channel_ready`
// which would be the case for pending inbound/outbound channels.
context.update_config(&config);
if let ChannelPhase::Funded(channel) = channel_phase {
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
node_id: channel.context.get_counterparty_node_id(),
msg,
});
}
}
continue;
Expand Down

0 comments on commit c67d033

Please sign in to comment.