Skip to content

Commit 764faf8

Browse files
committed
Fix minimal contribution at 10% of final_value_msat
1 parent 6e00c28 commit 764faf8

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

lightning/src/routing/router.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,8 @@ where L::Target: Logger {
847847
let mut used_channel_liquidities: HashMap<(u64, bool), u64> =
848848
HashMap::with_capacity(network_nodes.len());
849849

850-
// Keeping track of how much value we already collected across other paths. Helps to decide:
851-
// - how much a new path should be transferring (upper bound);
852-
// - whether a channel should be disregarded because
853-
// it's available liquidity is too small comparing to how much more we need to collect;
854-
// - when we want to stop looking for new paths.
850+
// Keeping track of how much value we already collected across other paths. Helps to decide
851+
// when we want to stop looking for new paths.
855852
let mut already_collected_value_msat = 0;
856853

857854
for (_, channels) in first_hop_targets.iter_mut() {
@@ -920,16 +917,12 @@ where L::Target: Logger {
920917
// Taking too many smaller paths also increases the chance of payment failure.
921918
// Thus to avoid this effect, we require from our collected links to provide
922919
// at least a minimal contribution to the recommended value yet-to-be-fulfilled.
923-
//
924-
// This requirement is currently 5% of the remaining-to-be-collected value.
925-
// This means as we successfully advance in our collection,
926-
// the absolute liquidity contribution is lowered,
927-
// thus increasing the number of potential channels to be selected.
920+
// This requirement is currently 10% of the value.
928921

929-
// Derive the minimal liquidity contribution with a ratio of 20 (5%, rounded up)
922+
// Derive the minimal liquidity contribution with a ratio of 10 (10%, rounded up)
930923
// or 100% if we're not allowed to do multipath payments.
931924
let minimal_value_contribution_msat: u64 = if allow_mpp {
932-
(recommended_value_msat - already_collected_value_msat + 19) / 20
925+
(final_value_msat + 9) / 10
933926
} else {
934927
final_value_msat
935928
};
@@ -1504,10 +1497,8 @@ where L::Target: Logger {
15041497
*used_channel_liquidities.entry((victim_scid, true)).or_default() = exhausted;
15051498
}
15061499

1507-
// Track the total amount all our collected paths allow to send so that we:
1508-
// - know when to stop looking for more paths
1509-
// - know which of the hops are useless considering how much more sats we need
1510-
// (contributes_sufficient_value)
1500+
// Track the total amount all our collected paths allow to send so that we know
1501+
// when to stop looking for more paths
15111502
already_collected_value_msat += value_contribution_msat;
15121503

15131504
payment_paths.push(payment_path);

0 commit comments

Comments
 (0)