- let curr_hop_path_idx = path.hops.len() - 1 - idx;
- scorer.channel_penalty_msat(hop.short_channel_id, &NodeId::from_pubkey(&path.hops[curr_hop_path_idx - 1].pubkey), &NodeId::from_pubkey(&hop.pubkey), usage, &());
+ let network_graph = self.network_graph.read_only();
+ let channel = match network_graph.channel(hop.short_channel_id) {
+ Some(channel) => channel,
+ None => continue,
+ };
+ let channel = match channel.as_directed_to(&NodeId::from_pubkey(&hop.pubkey)) {
+ Some(channel) => channel,
+ None => panic!("Channel directed to {} was not found", hop.pubkey),
+ };
+ let candidate = CandidateRouteHop::PublicHop {
+ info: channel.0,
+ short_channel_id: hop.short_channel_id,
+ };
+ scorer.channel_penalty_msat(&candidate, usage, &());