Skip to content

Commit 1d69362

Browse files
committed
Use ChannelUsage.
1 parent 6231d69 commit 1d69362

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lightning/src/routing/router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,8 +1810,6 @@ fn build_route_from_hops_internal<L: Deref>(
18101810
network_graph: &ReadOnlyNetworkGraph, final_value_msat: u64, final_cltv_expiry_delta: u32,
18111811
logger: L, random_seed_bytes: &[u8; 32]) -> Result<Route, LightningError> where L::Target: Logger {
18121812

1813-
let filter_channels = |_short_channel_id: u64, _send_amt_msat: u64, _capacity_msat: u64,
1814-
source: &NodeId, target: &NodeId| {
18151813

18161814
let node_ids_iter = hops.iter().map(|hop_pubkey| NodeId::from_pubkey(&hop_pubkey));
18171815
let mut hop_iter = core::iter::once(NodeId::from_pubkey(&our_node_pubkey))
@@ -1825,6 +1823,8 @@ fn build_route_from_hops_internal<L: Deref>(
18251823
Some(_) => 0,
18261824
None => u64::max_value()
18271825
}
1826+
let filter_channels = |_short_channel_id: u64, source: &NodeId, target: &NodeId,
1827+
_usage: ChannelUsage| {
18281828
};
18291829

18301830
let scorer = DynamicPenaltyScorer::with_penalty_func(filter_channels);

lightning/src/routing/scoring.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,18 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
260260
}
261261

262262
/// [`Score`] implementation that uses a dynamic penalty.
263+
///
264+
/// (C-not exported)
263265
pub struct DynamicPenaltyScorer<F>
264266
where
265-
F: Fn(u64, u64, u64, &NodeId, &NodeId) -> u64,
267+
F: Fn(u64, &NodeId, &NodeId, ChannelUsage) -> u64,
266268
{
267269
penalty_func: F,
268270
}
269271

270272
impl<F> DynamicPenaltyScorer<F>
271273
where
272-
F: Fn(u64, u64, u64, &NodeId, &NodeId) -> u64,
274+
F: Fn(u64, &NodeId, &NodeId, ChannelUsage) -> u64,
273275
{
274276
/// Creates a new scorer that applies a closure `penalty_func`, which takes the same arguments
275277
/// as [`Score::channel_penalty_msat`].
@@ -281,12 +283,12 @@ where
281283

282284
impl<F> Score for DynamicPenaltyScorer<F>
283285
where
284-
F: Fn(u64, u64, u64, &NodeId, &NodeId) -> u64,
286+
F: Fn(u64, &NodeId, &NodeId, ChannelUsage) -> u64,
285287
{
286-
fn channel_penalty_msat(&self, short_channel_id: u64, send_amt_msat: u64, capacity_msat: u64,
287-
source: &NodeId, target: &NodeId) -> u64
288+
fn channel_penalty_msat(&self, short_channel_id: u64, source: &NodeId, target: &NodeId,
289+
usage: ChannelUsage) -> u64
288290
{
289-
(self.penalty_func)(short_channel_id, send_amt_msat, capacity_msat, source, target)
291+
(self.penalty_func)(short_channel_id, source, target, usage)
290292
}
291293

292294
fn payment_path_failed(&mut self, _path: &[&RouteHop], _short_channel_id: u64) {}
@@ -296,7 +298,7 @@ where
296298

297299
impl<F> Writeable for DynamicPenaltyScorer<F>
298300
where
299-
F: Fn(u64, u64, u64, &NodeId, &NodeId) -> u64,
301+
F: Fn(u64, &NodeId, &NodeId, ChannelUsage) -> u64,
300302
{
301303
#[inline]
302304
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
@@ -307,7 +309,7 @@ where
307309

308310
impl<F> ReadableArgs<F> for DynamicPenaltyScorer<F>
309311
where
310-
F: Fn(u64, u64, u64, &NodeId, &NodeId) -> u64,
312+
F: Fn(u64, &NodeId, &NodeId, ChannelUsage) -> u64,
311313
{
312314
#[inline]
313315
fn read<R: Read>(r: &mut R, penalty_func: F) -> Result<Self, DecodeError> {

0 commit comments

Comments
 (0)