Skip to content

Commit 9175523

Browse files
committed
Also sort by a PaymentPaths scoring.
1 parent 3c69c91 commit 9175523

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ impl<'a> PaymentPath<'a> {
495495
self.hops.last().unwrap().0.fee_msat
496496
}
497497

498+
fn get_path_penalty_msat(&self) -> u64 {
499+
if self.hops.len() < 1 {
500+
return u64::max_value();
501+
}
502+
self.hops.first().unwrap().0.path_penalty_msat
503+
}
504+
498505
fn get_total_fee_paid_msat(&self) -> u64 {
499506
if self.hops.len() < 1 {
500507
return 0;
@@ -1483,7 +1490,8 @@ where L::Target: Logger {
14831490
cur_route.sort_unstable_by(|a, b| {
14841491
a.get_value_msat().cmp(&b.get_value_msat())
14851492
// Reverse ordering for fees, so we drop higher-fee paths first
1486-
.then_with(|| b.get_total_fee_paid_msat().cmp(&a.get_total_fee_paid_msat()))
1493+
.then_with(|| b.get_total_fee_paid_msat().saturating_add(b.get_path_penalty_msat())
1494+
.cmp(&a.get_total_fee_paid_msat().saturating_add(a.get_path_penalty_msat())))
14871495
});
14881496

14891497
// We should make sure that at least 1 path left.

0 commit comments

Comments
 (0)