File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -511,6 +511,10 @@ impl<'a> PaymentPath<'a> {
511511 return result;
512512 }
513513
514+ fn get_cost_msat ( & self ) -> u64 {
515+ self . get_total_fee_paid_msat ( ) . saturating_add ( self . get_path_penalty_msat ( ) )
516+ }
517+
514518 // If the amount transferred by the path is updated, the fees should be adjusted. Any other way
515519 // to change fees may result in an inconsistency.
516520 //
@@ -1548,8 +1552,8 @@ where L::Target: Logger {
15481552 }
15491553
15501554 // Step (9).
1551- // Select the best route by lowest total fee .
1552- drawn_routes. sort_unstable_by_key ( |paths| paths. iter ( ) . map ( |path| path. get_total_fee_paid_msat ( ) ) . sum :: < u64 > ( ) ) ;
1555+ // Select the best route by lowest total cost .
1556+ drawn_routes. sort_unstable_by_key ( |paths| paths. iter ( ) . map ( |path| path. get_cost_msat ( ) ) . sum :: < u64 > ( ) ) ;
15531557 let mut selected_paths = Vec :: < Vec < Result < RouteHop , LightningError > > > :: new ( ) ;
15541558 for payment_path in drawn_routes. first ( ) . unwrap ( ) {
15551559 let mut path = payment_path. hops . iter ( ) . map ( |( payment_hop, node_features) | {
You can’t perform that action at this time.
0 commit comments