@@ -885,18 +885,11 @@ impl<'a> PaymentPath<'a> {
885
885
}
886
886
}
887
887
888
+ #[ inline( always) ]
889
+ /// Calculate the fees required to route the given amount over a channel with the given fees.
888
890
fn 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 ) )
900
893
}
901
894
902
895
/// 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 {
1289
1282
if !should_process { should_process = true ; }
1290
1283
}
1291
1284
1292
- if should_process {
1285
+ ' processing_node : while should_process {
1293
1286
let mut hop_use_fee_msat = 0 ;
1294
1287
let mut total_fee_msat = $next_hops_fee_msat;
1295
1288
@@ -1299,7 +1292,7 @@ where L::Target: Logger {
1299
1292
match compute_fees( amount_to_transfer_over_msat, $candidate. fees( ) ) {
1300
1293
// max_value means we'll always fail
1301
1294
// the old_entry.total_fee_msat > total_fee_msat check
1302
- None => total_fee_msat = u64 :: max_value ( ) ,
1295
+ None => break ' processing_node ,
1303
1296
Some ( fee_msat) => {
1304
1297
hop_use_fee_msat = fee_msat;
1305
1298
total_fee_msat += hop_use_fee_msat;
@@ -1392,6 +1385,7 @@ where L::Target: Logger {
1392
1385
) ;
1393
1386
}
1394
1387
}
1388
+ break ' processing_node;
1395
1389
}
1396
1390
}
1397
1391
}
0 commit comments