- let mut lowest_inbound_channel_fee_base_msat = u32::max_value();
- let mut lowest_inbound_channel_fee_proportional_millionths = u32::max_value();
-
- {
- let node = self.nodes.get(&dest_node_id).unwrap();
-
- for chan_id in node.channels.iter() {
- let chan = self.channels.get(chan_id).unwrap();
- // Since direction was enabled, the channel indeed had directional info
- let chan_info;
- if chan.node_one == dest_node_id {
- chan_info = chan.two_to_one.as_ref().unwrap();
- } else {
- chan_info = chan.one_to_two.as_ref().unwrap();
+ let mut node = self.nodes.get_mut(&dest_node_id).unwrap();
+ let mut lowest_inbound_channel_fees = None;
+
+ for chan_id in node.channels.iter() {
+ let chan = self.channels.get(chan_id).unwrap();
+ let chan_info_opt;
+ if chan.node_one == dest_node_id {
+ chan_info_opt = chan.two_to_one.as_ref();
+ } else {
+ chan_info_opt = chan.one_to_two.as_ref();
+ }
+ if let Some(chan_info) = chan_info_opt {
+ if chan_info.enabled {
+ let fees = lowest_inbound_channel_fees.get_or_insert(RoutingFees {
+ base_msat: u32::max_value(), proportional_millionths: u32::max_value() });
+ fees.base_msat = cmp::min(fees.base_msat, chan_info.fees.base_msat);
+ fees.proportional_millionths = cmp::min(fees.proportional_millionths, chan_info.fees.proportional_millionths);