@@ -2024,6 +2024,32 @@ impl<'a> fmt::Display for LoggedCandidateHop<'a> {
2024
2024
}
2025
2025
}
2026
2026
2027
+
2028
+ // Remember how many candidates we ignored to allow for some logging afterwards.
2029
+ #[ derive( Default ) ]
2030
+ struct IgnoredCandidatesStats {
2031
+ value_contribution : u32 ,
2032
+ cltv_delta_limit : u32 ,
2033
+ path_length_limit : u32 ,
2034
+ previously_failed : u32 ,
2035
+ total_fee_limit : u32 ,
2036
+ avoid_overpayment : u32 ,
2037
+ htlc_minimum_msat_limit : u32 ,
2038
+ }
2039
+
2040
+ impl IgnoredCandidatesStats {
2041
+ // Return total number of ignored cantotal number of ignored candidates.
2042
+ const fn ignored_total ( & self ) -> u32 {
2043
+ self . value_contribution +
2044
+ self . cltv_delta_limit +
2045
+ self . path_length_limit +
2046
+ self . previously_failed +
2047
+ self . total_fee_limit +
2048
+ self . avoid_overpayment +
2049
+ self . htlc_minimum_msat_limit
2050
+ }
2051
+ }
2052
+
2027
2053
#[ inline]
2028
2054
fn sort_first_hop_channels (
2029
2055
channels : & mut Vec < & ChannelDetails > , used_liquidities : & HashMap < CandidateHopId , u64 > ,
@@ -2345,14 +2371,9 @@ where L::Target: Logger {
2345
2371
log_trace ! ( logger, "Building path from {} to payer {} for value {} msat." ,
2346
2372
LoggedPayeePubkey ( payment_params. payee. node_id( ) ) , our_node_pubkey, final_value_msat) ;
2347
2373
2374
+
2348
2375
// Remember how many candidates we ignored to allow for some logging afterwards.
2349
- let mut num_ignored_value_contribution: u32 = 0 ;
2350
- let mut num_ignored_path_length_limit: u32 = 0 ;
2351
- let mut num_ignored_cltv_delta_limit: u32 = 0 ;
2352
- let mut num_ignored_previously_failed: u32 = 0 ;
2353
- let mut num_ignored_total_fee_limit: u32 = 0 ;
2354
- let mut num_ignored_avoid_overpayment: u32 = 0 ;
2355
- let mut num_ignored_htlc_minimum_msat_limit: u32 = 0 ;
2376
+ let mut ignored_stats = IgnoredCandidatesStats :: default ( ) ;
2356
2377
2357
2378
macro_rules! add_entry {
2358
2379
// Adds entry which goes from $candidate.source() to $candidate.target() over the $candidate hop.
@@ -2370,13 +2391,7 @@ where L::Target: Logger {
2370
2391
final_cltv_expiry_delta,
2371
2392
recommended_value_msat,
2372
2393
& logger,
2373
- & mut num_ignored_value_contribution,
2374
- & mut num_ignored_path_length_limit,
2375
- & mut num_ignored_cltv_delta_limit,
2376
- & mut num_ignored_previously_failed,
2377
- & mut num_ignored_total_fee_limit,
2378
- & mut num_ignored_avoid_overpayment,
2379
- & mut num_ignored_htlc_minimum_msat_limit,
2394
+ & mut ignored_stats,
2380
2395
& mut hit_minimum_limit,
2381
2396
& mut dist,
2382
2397
our_node_id,
@@ -2924,17 +2939,14 @@ where L::Target: Logger {
2924
2939
}
2925
2940
}
2926
2941
2927
- let num_ignored_total = num_ignored_value_contribution + num_ignored_path_length_limit +
2928
- num_ignored_cltv_delta_limit + num_ignored_previously_failed +
2929
- num_ignored_avoid_overpayment + num_ignored_htlc_minimum_msat_limit +
2930
- num_ignored_total_fee_limit;
2942
+ let num_ignored_total = ignored_stats. ignored_total ( ) ;
2931
2943
if num_ignored_total > 0 {
2932
2944
log_trace ! ( logger,
2933
2945
"Ignored {} candidate hops due to insufficient value contribution, {} due to path length limit, {} due to CLTV delta limit, {} due to previous payment failure, {} due to htlc_minimum_msat limit, {} to avoid overpaying, {} due to maximum total fee limit. Total: {} ignored candidates." ,
2934
- num_ignored_value_contribution , num_ignored_path_length_limit ,
2935
- num_ignored_cltv_delta_limit , num_ignored_previously_failed ,
2936
- num_ignored_htlc_minimum_msat_limit , num_ignored_avoid_overpayment ,
2937
- num_ignored_total_fee_limit , num_ignored_total) ;
2946
+ ignored_stats . value_contribution , ignored_stats . path_length_limit ,
2947
+ ignored_stats . cltv_delta_limit , ignored_stats . previously_failed ,
2948
+ ignored_stats . htlc_minimum_msat_limit , ignored_stats . avoid_overpayment ,
2949
+ ignored_stats . total_fee_limit , num_ignored_total) ;
2938
2950
}
2939
2951
2940
2952
// Step (5).
@@ -3108,13 +3120,7 @@ fn add_entry_internal<'a, L: Deref, S: ScoreLookUp>(
3108
3120
final_cltv_expiry_delta : u32 ,
3109
3121
recommended_value_msat : u64 ,
3110
3122
logger : & L ,
3111
- num_ignored_value_contribution : & mut u32 ,
3112
- num_ignored_path_length_limit : & mut u32 ,
3113
- num_ignored_cltv_delta_limit : & mut u32 ,
3114
- num_ignored_previously_failed : & mut u32 ,
3115
- num_ignored_total_fee_limit : & mut u32 ,
3116
- num_ignored_avoid_overpayment : & mut u32 ,
3117
- num_ignored_htlc_minimum_msat_limit : & mut u32 ,
3123
+ ignored_stats : & mut IgnoredCandidatesStats ,
3118
3124
hit_minimum_limit : & mut bool ,
3119
3125
dist : & mut Vec < Option < PathBuildingHop < ' a > > > ,
3120
3126
our_node_id : NodeId ,
@@ -3228,12 +3234,12 @@ where
3228
3234
LoggedCandidateHop ( & candidate) ,
3229
3235
effective_capacity) ;
3230
3236
}
3231
- * num_ignored_value_contribution += 1 ;
3237
+ ignored_stats . value_contribution += 1 ;
3232
3238
} else if exceeds_max_path_length {
3233
3239
if should_log_candidate {
3234
3240
log_trace ! ( logger, "Ignoring {} due to exceeding maximum path length limit." , LoggedCandidateHop ( & candidate) ) ;
3235
3241
}
3236
- * num_ignored_path_length_limit += 1 ;
3242
+ ignored_stats . path_length_limit += 1 ;
3237
3243
} else if exceeds_cltv_delta_limit {
3238
3244
if should_log_candidate {
3239
3245
log_trace ! ( logger, "Ignoring {} due to exceeding CLTV delta limit." , LoggedCandidateHop ( & candidate) ) ;
@@ -3246,19 +3252,19 @@ where
3246
3252
) ;
3247
3253
}
3248
3254
}
3249
- * num_ignored_cltv_delta_limit += 1 ;
3255
+ ignored_stats . cltv_delta_limit += 1 ;
3250
3256
} else if payment_failed_on_this_channel {
3251
3257
if should_log_candidate {
3252
3258
log_trace ! ( logger, "Ignoring {} due to a failed previous payment attempt." , LoggedCandidateHop ( & candidate) ) ;
3253
3259
}
3254
- * num_ignored_previously_failed += 1 ;
3260
+ ignored_stats . previously_failed += 1 ;
3255
3261
} else if may_overpay_to_meet_path_minimum_msat {
3256
3262
if should_log_candidate {
3257
3263
log_trace ! ( logger,
3258
3264
"Ignoring {} to avoid overpaying to meet htlc_minimum_msat limit ({})." ,
3259
3265
LoggedCandidateHop ( & candidate) , candidate. htlc_minimum_msat( ) ) ;
3260
3266
}
3261
- * num_ignored_avoid_overpayment += 1 ;
3267
+ ignored_stats . avoid_overpayment += 1 ;
3262
3268
* hit_minimum_limit = true ;
3263
3269
} else if over_path_minimum_msat {
3264
3270
// Note that low contribution here (limited by available_liquidity_msat)
@@ -3330,7 +3336,7 @@ where
3330
3336
) ;
3331
3337
}
3332
3338
}
3333
- * num_ignored_total_fee_limit += 1 ;
3339
+ ignored_stats . total_fee_limit += 1 ;
3334
3340
} else {
3335
3341
let channel_usage = ChannelUsage {
3336
3342
amount_msat : amount_to_transfer_over_msat,
@@ -3431,7 +3437,7 @@ where
3431
3437
) ;
3432
3438
}
3433
3439
}
3434
- * num_ignored_htlc_minimum_msat_limit += 1 ;
3440
+ ignored_stats . htlc_minimum_msat_limit += 1 ;
3435
3441
}
3436
3442
}
3437
3443
}
0 commit comments