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> {
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.
You can’t perform that action at this time.
0 commit comments