File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,13 @@ impl<'a> PaymentPath<'a> {
495
495
self . hops . last ( ) . unwrap ( ) . 0 . fee_msat
496
496
}
497
497
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
+
498
505
fn get_total_fee_paid_msat ( & self ) -> u64 {
499
506
if self . hops . len ( ) < 1 {
500
507
return 0 ;
@@ -1483,7 +1490,8 @@ where L::Target: Logger {
1483
1490
cur_route. sort_unstable_by ( |a, b| {
1484
1491
a. get_value_msat ( ) . cmp ( & b. get_value_msat ( ) )
1485
1492
// 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 ( ) ) ) )
1487
1495
} ) ;
1488
1496
1489
1497
// We should make sure that at least 1 path left.
You can’t perform that action at this time.
0 commit comments