Skip to content

Commit 30b6873

Browse files
committed
Correctly pick middle hop to victimize
For even-length paths, preferring a later hop avoids overly limiting the possible paths on the next iteration.
1 parent 37a947b commit 30b6873

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ where L::Target: Logger {
13901390
// If we weren't capped by hitting a liquidity limit on a channel in the path,
13911391
// we'll probably end up picking the same path again on the next iteration.
13921392
// Decrease the available liquidity of a hop in the middle of the path.
1393-
let victim_scid = payment_path.hops[(payment_path.hops.len() - 1) / 2].0.candidate.short_channel_id();
1393+
let victim_scid = payment_path.hops[(payment_path.hops.len()) / 2].0.candidate.short_channel_id();
13941394
log_trace!(logger, "Disabling channel {} for future path building iterations to avoid duplicates.", victim_scid);
13951395
let victim_liquidity = bookkept_channels_liquidity_available_msat.get_mut(&victim_scid).unwrap();
13961396
*victim_liquidity = 0;

0 commit comments

Comments
 (0)