Skip to content

Commit

Permalink
f one less closure
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Sep 12, 2024
1 parent 3a00cd8 commit 0325c14
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2333,29 +2333,26 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
if let Some(channel) = channels.get_mut(&msg.short_channel_id) {
check_msg_sanity(channel)?;

let get_new_channel_info = || {
let last_update_message = if msg.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY
{ full_msg.cloned() } else { None };

let updated_channel_update_info = ChannelUpdateInfo {
enabled: chan_enabled,
last_update: msg.timestamp,
cltv_expiry_delta: msg.cltv_expiry_delta,
htlc_minimum_msat: msg.htlc_minimum_msat,
htlc_maximum_msat: msg.htlc_maximum_msat,
fees: RoutingFees {
base_msat: msg.fee_base_msat,
proportional_millionths: msg.fee_proportional_millionths,
},
last_update_message
};
Some(updated_channel_update_info)
};
let last_update_message = if msg.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY
{ full_msg.cloned() } else { None };

let new_channel_info = Some(ChannelUpdateInfo {
enabled: chan_enabled,
last_update: msg.timestamp,
cltv_expiry_delta: msg.cltv_expiry_delta,
htlc_minimum_msat: msg.htlc_minimum_msat,
htlc_maximum_msat: msg.htlc_maximum_msat,
fees: RoutingFees {
base_msat: msg.fee_base_msat,
proportional_millionths: msg.fee_proportional_millionths,
},
last_update_message
});

if msg.channel_flags & 1 == 1 {
channel.two_to_one = get_new_channel_info();
channel.two_to_one = new_channel_info;
} else {
channel.one_to_two = get_new_channel_info();
channel.one_to_two = new_channel_info;
}
}

Expand Down

0 comments on commit 0325c14

Please sign in to comment.