f - Remove node_id from ProbabilisticScorer
[rust-lightning] / lightning / src / routing / router.rs
index b1e24627d9e0c06fa4901088e12a069524b474d6..ed40f4641a4a0c109683acffd29ead94a007fcd5 100644 (file)
@@ -373,6 +373,7 @@ impl<'a> CandidateRouteHop<'a> {
                }
        }
 
+       // NOTE: This may copy bytes to so avoid calling it in a hot code path.
        fn features(&self) -> ChannelFeatures {
                match self {
                        CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(),
@@ -1071,10 +1072,8 @@ where L::Target: Logger {
                                        for chan_id in $node.channels.iter() {
                                                let chan = network_channels.get(chan_id).unwrap();
                                                if !chan.features.requires_unknown_bits() {
-                                                       let directed_channel =
+                                                       let (directed_channel, source) =
                                                                chan.as_directed_to(&$node_id).expect("inconsistent NetworkGraph");
-                                                       let source = directed_channel.source();
-                                                       let target = directed_channel.target();
                                                        if first_hops.is_none() || *source != our_node_id {
                                                                if let Some(direction) = directed_channel.direction() {
                                                                        if direction.enabled {
@@ -1082,7 +1081,7 @@ where L::Target: Logger {
                                                                                        info: directed_channel.with_update().unwrap(),
                                                                                        short_channel_id: *chan_id,
                                                                                };
-                                                                               add_entry!(candidate, *source, *target, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat, $next_hops_path_penalty_msat, $next_hops_cltv_delta);
+                                                                               add_entry!(candidate, *source, $node_id, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat, $next_hops_path_penalty_msat, $next_hops_cltv_delta);
                                                                        }
                                                                }
                                                        }
@@ -1157,7 +1156,7 @@ where L::Target: Logger {
                                        let candidate = network_channels
                                                .get(&hop.short_channel_id)
                                                .and_then(|channel| channel.as_directed_to(&target))
-                                               .and_then(|channel| channel.with_update())
+                                               .and_then(|(channel, _)| channel.with_update())
                                                .map(|info| CandidateRouteHop::PublicHop {
                                                        info,
                                                        short_channel_id: hop.short_channel_id,