@@ -178,8 +178,7 @@ pub const DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = 1008;
178
178
179
179
/// Maximum number of paths we allow an MPP payment to have.
180
180
// The default limit is currently set rather arbitrary - there aren't any real fundamental path-count
181
- // limits. After we support retrying individual paths we should likely bump this, but
182
- // for now more than 10 paths likely carries too much one-path failure.
181
+ // limits, but for now more than 10 paths likely carries too much one-path failure.
183
182
pub const DEFAULT_MAX_MPP_PATH_COUNT : u8 = 10 ;
184
183
185
184
// The median hop CLTV expiry delta currently seen in the network.
@@ -220,9 +219,11 @@ pub struct PaymentParameters {
220
219
pub expiry_time : Option < u64 > ,
221
220
222
221
/// The maximum total CLTV delta we accept for the route.
222
+ /// Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`].
223
223
pub max_total_cltv_expiry_delta : u32 ,
224
224
225
225
/// The maximum number of paths that may be used by MPP payments.
226
+ /// Defaults to [`DEFAULT_MAX_MPP_PATH_COUNT`].
226
227
pub max_mpp_path_count : u8 ,
227
228
}
228
229
@@ -863,6 +864,21 @@ where L::Target: Logger {
863
864
let recommended_value_msat = final_value_msat * ROUTE_CAPACITY_PROVISION_FACTOR as u64 ;
864
865
let mut path_value_msat = final_value_msat;
865
866
867
+ // Routing Fragmentation Mitigation heuristic:
868
+ //
869
+ // Routing fragmentation across many payment paths increases the overall routing
870
+ // fees as you have irreducible routing fees per-link used (`fee_base_msat`).
871
+ // Taking too many smaller paths also increases the chance of payment failure.
872
+ // Thus to avoid this effect, we require from our collected links to provide
873
+ // at least a minimal contribution to the recommended value yet-to-be-fulfilled.
874
+ // This requirement is currently set to be 1/max_mpp_path_count of the payment
875
+ // value to ensure we only ever return routes that do not violate this limit.
876
+ let minimal_value_contribution_msat: u64 = if allow_mpp {
877
+ ( final_value_msat + ( payment_params. max_mpp_path_count as u64 - 1 ) ) / payment_params. max_mpp_path_count as u64
878
+ } else {
879
+ final_value_msat
880
+ } ;
881
+
866
882
// Keep track of how much liquidity has been used in selected channels. Used to determine
867
883
// if the channel can be used by additional MPP paths or to inform path finding decisions. It is
868
884
// aware of direction *only* to ensure that the correct htlc_maximum_msat value is used. Hence,
@@ -933,20 +949,6 @@ where L::Target: Logger {
933
949
* used_liquidity_msat
934
950
} ) ;
935
951
936
- // Routing Fragmentation Mitigation heuristic:
937
- //
938
- // Routing fragmentation across many payment paths increases the overall routing
939
- // fees as you have irreducible routing fees per-link used (`fee_base_msat`).
940
- // Taking too many smaller paths also increases the chance of payment failure.
941
- // Thus to avoid this effect, we require from our collected links to provide
942
- // at least a minimal contribution to the recommended value yet-to-be-fulfilled.
943
- // This requirement is currently set to be 1/max_mpp_path_count of the payment
944
- // value to ensure we only ever return routes that do not violate this limit.
945
- let minimal_value_contribution_msat: u64 = if allow_mpp {
946
- ( final_value_msat + ( payment_params. max_mpp_path_count as u64 - 1 ) ) / payment_params. max_mpp_path_count as u64
947
- } else {
948
- final_value_msat
949
- } ;
950
952
// Verify the liquidity offered by this channel complies to the minimal contribution.
951
953
let contributes_sufficient_value = available_value_contribution_msat >= minimal_value_contribution_msat;
952
954
// Do not consider candidate hops that would exceed the maximum path length.
@@ -1691,7 +1693,7 @@ where L::Target: Logger {
1691
1693
selected_paths. push ( path) ;
1692
1694
}
1693
1695
// Make sure we would never create a route with more paths than we allow.
1694
- assert ! ( selected_paths. len( ) <= payment_params. max_mpp_path_count. into( ) ) ;
1696
+ debug_assert ! ( selected_paths. len( ) <= payment_params. max_mpp_path_count. into( ) ) ;
1695
1697
1696
1698
if let Some ( features) = & payment_params. features {
1697
1699
for path in selected_paths. iter_mut ( ) {
0 commit comments