@@ -885,18 +885,11 @@ impl<'a> PaymentPath<'a> {
885885 }
886886}
887887
888+ #[ inline( always) ]
889+ /// Calculate the fees required to route the given amount over a channel with the given fees.
888890fn compute_fees ( amount_msat : u64 , channel_fees : RoutingFees ) -> Option < u64 > {
889- let proportional_fee_millions =
890- amount_msat. checked_mul ( channel_fees. proportional_millionths as u64 ) ;
891- if let Some ( new_fee) = proportional_fee_millions. and_then ( |part| {
892- ( channel_fees. base_msat as u64 ) . checked_add ( part / 1_000_000 ) } ) {
893-
894- Some ( new_fee)
895- } else {
896- // This function may be (indirectly) called without any verification,
897- // with channel_fees provided by a caller. We should handle it gracefully.
898- None
899- }
891+ amount_msat. checked_mul ( channel_fees. proportional_millionths as u64 )
892+ . and_then ( |part| ( channel_fees. base_msat as u64 ) . checked_add ( part / 1_000_000 ) )
900893}
901894
902895/// The default `features` we assume for a node in a route, when no `features` are known about that
@@ -1289,7 +1282,7 @@ where L::Target: Logger {
12891282 if !should_process { should_process = true ; }
12901283 }
12911284
1292- if should_process {
1285+ ' processing_node : while should_process {
12931286 let mut hop_use_fee_msat = 0 ;
12941287 let mut total_fee_msat = $next_hops_fee_msat;
12951288
@@ -1299,7 +1292,7 @@ where L::Target: Logger {
12991292 match compute_fees( amount_to_transfer_over_msat, $candidate. fees( ) ) {
13001293 // max_value means we'll always fail
13011294 // the old_entry.total_fee_msat > total_fee_msat check
1302- None => total_fee_msat = u64 :: max_value ( ) ,
1295+ None => break ' processing_node ,
13031296 Some ( fee_msat) => {
13041297 hop_use_fee_msat = fee_msat;
13051298 total_fee_msat += hop_use_fee_msat;
@@ -1392,6 +1385,7 @@ where L::Target: Logger {
13921385 ) ;
13931386 }
13941387 }
1388+ break ' processing_node;
13951389 }
13961390 }
13971391 }
0 commit comments