Skip to content

Commit 9b9dbcc

Browse files
committed
f describe new pathfinding score in comment
1 parent c1f4903 commit 9b9dbcc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,13 @@ where L::Target: Logger {
30073007
.saturating_add(old_entry.path_penalty_msat);
30083008
let new_fee_cost = cmp::max(total_fee_msat, path_htlc_minimum_msat)
30093009
.saturating_add(path_penalty_msat);
3010+
// The actual score we use for our heap is the cost divided by how
3011+
// much we are thinking of sending over this channel. This avoids
3012+
// prioritizing channels that have a very low fee because we aren't
3013+
// sending very much over them.
3014+
// In order to avoid integer division precision loss, we simply
3015+
// shift the costs up to the top half of a u128 and divide by the
3016+
// value (which is, at max, just under a u64).
30103017
let old_cost = if old_fee_cost != u64::MAX && old_entry.value_contribution_msat != 0 {
30113018
((old_fee_cost as u128) << 64) / old_entry.value_contribution_msat as u128
30123019
} else {

0 commit comments

Comments
 (0)