|
55 | 55 | //! [`find_route`]: crate::routing::router::find_route |
56 | 56 |
|
57 | 57 | use ln::msgs::DecodeError; |
58 | | -use routing::network_graph::{NetworkGraph, NodeId}; |
| 58 | +use routing::network_graph::{ChannelUpdateInfo, NetworkGraph, NodeId}; |
59 | 59 | use routing::router::RouteHop; |
60 | 60 | use util::ser::{Readable, ReadableArgs, Writeable, Writer}; |
61 | 61 | use util::logger::Logger; |
@@ -632,26 +632,21 @@ impl<G: Deref<Target = NetworkGraph>, L: Deref, T: Time> ProbabilisticScorerUsin |
632 | 632 | let graph = self.network_graph.read_only(); |
633 | 633 | for (scid, liq) in self.channel_liquidities.iter() { |
634 | 634 | if let Some(chan_debug) = graph.channels().get(scid) { |
635 | | - if let Some(dir_debug) = &chan_debug.one_to_two { |
636 | | - let amount = chan_debug.capacity_sats.map(|v| v*1000).or(dir_debug.htlc_maximum_msat); |
637 | | - if let Some(amt) = amount { |
638 | | - let dir_liq = liq.as_directed(&chan_debug.node_one, &chan_debug.node_two, amt, self.params.liquidity_offset_half_life); |
639 | | - log_debug!(self.logger, "Liquidity from {:?} to {:?} via {} is in the range ({}, {})", |
640 | | - chan_debug.node_one, chan_debug.node_two, scid, dir_liq.min_liquidity_msat(), dir_liq.max_liquidity_msat()); |
641 | | - } else { |
642 | | - log_debug!(self.logger, "No amount known for SCID {} from {:?} to {:?}", scid, chan_debug.node_one, chan_debug.node_two); |
643 | | - } |
644 | | - } |
645 | | - if let Some(dir_debug) = &chan_debug.two_to_one { |
646 | | - let amount = chan_debug.capacity_sats.map(|v| v*1000).or(dir_debug.htlc_maximum_msat); |
647 | | - if let Some(amt) = amount { |
648 | | - let dir_liq = liq.as_directed(&chan_debug.node_two, &chan_debug.node_one, amt, self.params.liquidity_offset_half_life); |
649 | | - log_debug!(self.logger, "Liquidity from {:?} to {:?} via {} is in the range ({}, {})", |
650 | | - chan_debug.node_two, chan_debug.node_one, scid, dir_liq.min_liquidity_msat(), dir_liq.max_liquidity_msat()); |
651 | | - } else { |
652 | | - log_debug!(self.logger, "No amount known for SCID {} from {:?} to {:?}", scid, chan_debug.node_two, chan_debug.node_one); |
| 635 | + let log_direction = |dir: &Option<ChannelUpdateInfo>, sender, recipient| { |
| 636 | + if let Some(dir_debug) = dir { |
| 637 | + let amount = chan_debug.capacity_sats.map(|v| v*1000).or(dir_debug.htlc_maximum_msat); |
| 638 | + if let Some(amt) = amount { |
| 639 | + let dir_liq = liq.as_directed(sender, recipient, amt, self.params.liquidity_offset_half_life); |
| 640 | + log_debug!(self.logger, "Liquidity from {:?} to {:?} via {} is in the range ({}, {})", |
| 641 | + sender, recipient, scid, dir_liq.min_liquidity_msat(), dir_liq.max_liquidity_msat()); |
| 642 | + } else { |
| 643 | + log_debug!(self.logger, "No amount known for SCID {} from {:?} to {:?}", scid, sender, recipient); |
| 644 | + } |
653 | 645 | } |
654 | | - } |
| 646 | + }; |
| 647 | + |
| 648 | + log_direction(&chan_debug.one_to_two, &chan_debug.node_one, &chan_debug.node_two); |
| 649 | + log_direction(&chan_debug.two_to_one, &chan_debug.node_two, &chan_debug.node_one); |
655 | 650 | } else { |
656 | 651 | log_debug!(self.logger, "No network graph entry for SCID {}", scid); |
657 | 652 | } |
|
0 commit comments