Skip to content

Commit 5baea6e

Browse files
committed
Fix minimal contribution at 10% of final_value_msat
1 parent 8e5cf75 commit 5baea6e

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
@@ -846,11 +846,8 @@ where L::Target: Logger {
846846
let mut used_channel_liquidities: HashMap<(u64, bool), u64> =
847847
HashMap::with_capacity(network_nodes.len());
848848

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

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

928-
// Derive the minimal liquidity contribution with a ratio of 20 (5%, rounded up)
921+
// Derive the minimal liquidity contribution with a ratio of 10 (10%, rounded up)
929922
// or 100% if we're not allowed to do multipath payments.
930923
let minimal_value_contribution_msat: u64 = if allow_mpp {
931-
(recommended_value_msat - already_collected_value_msat + 19) / 20
924+
(final_value_msat + 9) / 10
932925
} else {
933926
final_value_msat
934927
};
@@ -1503,10 +1496,8 @@ where L::Target: Logger {
15031496
*used_channel_liquidities.entry((victim_scid, true)).or_default() = exhausted;
15041497
}
15051498

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

15121503
payment_paths.push(payment_path);

0 commit comments

Comments
 (0)