@@ -127,6 +127,7 @@ impl ProbingConfigBuilder {
127127 /// Start building a config that probes via random graph walks.
128128 ///
129129 /// `max_hops` is the upper bound on the number of hops in a randomly constructed path.
130+ /// Values below `2` are clamped to `2`.
130131 pub fn random_walk ( max_hops : usize ) -> Self {
131132 Self :: with_kind ( ProbingStrategyKind :: Random { max_hops } )
132133 }
@@ -219,6 +220,7 @@ impl ArcedProbingConfigBuilder {
219220 /// Creates a builder configured to probe via random graph walks.
220221 ///
221222 /// `max_hops` is the upper bound on the number of hops in a randomly constructed path.
223+ /// Values below `2` are clamped to `2`.
222224 #[ uniffi:: constructor]
223225 pub fn new_random_walk ( max_hops : u64 ) -> Arc < Self > {
224226 Arc :: new ( Self { inner : RwLock :: new ( ProbingConfigBuilder :: random_walk ( max_hops as usize ) ) } )
@@ -439,7 +441,7 @@ impl RandomStrategy {
439441 Self {
440442 network_graph,
441443 channel_manager,
442- max_hops : max_hops. clamp ( 1 , MAX_PATH_LENGTH_ESTIMATE as usize ) ,
444+ max_hops : max_hops. clamp ( 2 , MAX_PATH_LENGTH_ESTIMATE as usize ) ,
443445 min_amount_msat,
444446 max_amount_msat,
445447 }
@@ -633,7 +635,7 @@ impl RandomStrategy {
633635
634636impl ProbingStrategy for RandomStrategy {
635637 fn next_probe ( & self ) -> Option < Path > {
636- let target_hops = random_range ( 1 , self . max_hops as u64 ) as usize ;
638+ let target_hops = random_range ( 2 , self . max_hops as u64 ) as usize ;
637639 let amount_msat = random_range ( self . min_amount_msat , self . max_amount_msat ) ;
638640
639641 self . try_build_path ( target_hops, amount_msat)
0 commit comments