@@ -66,7 +66,7 @@ use crate::logger::{log_error, LdkLogger, LogLevel, LogWriter, Logger};
6666use crate :: message_handler:: NodeCustomMessageHandler ;
6767use crate :: payment:: asynchronous:: om_mailbox:: OnionMessageMailbox ;
6868use crate :: peer_store:: PeerStore ;
69- use crate :: probing:: { ProbingService , ProbingStrategy } ;
69+ use crate :: probing:: { HighCapacityStrategy , ProbingService , ProbingStrategy } ;
7070use crate :: runtime:: Runtime ;
7171use crate :: tx_broadcaster:: TransactionBroadcaster ;
7272use crate :: types:: {
@@ -144,6 +144,7 @@ struct ProbingServiceConfig {
144144
145145pub enum ProbingStrategyConfig {
146146 Custom { strategy : Arc < dyn ProbingStrategy + Send + Sync > } ,
147+ HighCapacity { max_targets_per_cycle : usize , target_cache_reuse_limit : usize } ,
147148}
148149
149150impl fmt:: Debug for ProbingStrategyConfig {
@@ -152,6 +153,14 @@ impl fmt::Debug for ProbingStrategyConfig {
152153 Self :: Custom { .. } => {
153154 f. debug_struct ( "Custom" ) . field ( "strategy" , & "<ProbingStrategy>" ) . finish ( )
154155 } ,
156+ Self :: HighCapacity {
157+ max_targets_per_cycle : max_targets,
158+ target_cache_reuse_limit : max_reloads,
159+ } => f
160+ . debug_struct ( "HighCapacity" )
161+ . field ( "max_targets" , max_targets)
162+ . field ( "max_reloads" , max_reloads)
163+ . finish ( ) ,
155164 }
156165 }
157166}
@@ -160,6 +169,13 @@ impl Clone for ProbingStrategyConfig {
160169 fn clone ( & self ) -> Self {
161170 match self {
162171 Self :: Custom { strategy } => Self :: Custom { strategy : Arc :: clone ( strategy) } ,
172+ Self :: HighCapacity {
173+ max_targets_per_cycle : max_targets,
174+ target_cache_reuse_limit : max_reloads,
175+ } => Self :: HighCapacity {
176+ max_targets_per_cycle : * max_targets,
177+ target_cache_reuse_limit : * max_reloads,
178+ } ,
163179 }
164180 }
165181}
@@ -548,6 +564,33 @@ impl NodeBuilder {
548564 self
549565 }
550566
567+ /// Configures the probing service with the built-in high-capacity strategy.
568+ ///
569+ /// Targets peers with the highest total channel capacity to assess liquidity
570+ /// on the most significant network routes.
571+ ///
572+ /// # Parameters
573+ /// * `probing_interval_secs` - Seconds between probing cycles
574+ /// * `probing_amount_msat` - Amount in milli-satoshis per probe
575+ /// * `max_targets_per_cycle` - Maximum peers to probe each cycle
576+ /// * `target_cache_reuse_limit` - Number of cycles to reuse targets before refreshing.
577+ /// Acts as a cache: targets are reloaded from the network graph only after this many cycles,
578+ /// reducing overhead while adapting to network changes.
579+ pub fn set_probing_service_with_high_capacity_strategy (
580+ & mut self , probing_interval_secs : u64 , probing_amount_msat : u64 ,
581+ max_targets_per_cycle : usize , target_cache_reuse_limit : usize ,
582+ ) -> & mut Self {
583+ self . probing_service_config = Some ( ProbingServiceConfig {
584+ probing_interval_secs,
585+ probing_amount_msat,
586+ strategy : ProbingStrategyConfig :: HighCapacity {
587+ max_targets_per_cycle,
588+ target_cache_reuse_limit,
589+ } ,
590+ } ) ;
591+ self
592+ }
593+
551594 /// Sets the used storage directory path.
552595 pub fn set_storage_dir_path ( & mut self , storage_dir_path : String ) -> & mut Self {
553596 self . config . storage_dir_path = storage_dir_path;
@@ -1060,6 +1103,30 @@ impl ArcedNodeBuilder {
10601103 ) ;
10611104 }
10621105
1106+ /// Configures the probing service with the built-in high-capacity strategy.
1107+ ///
1108+ /// Targets peers with the highest total channel capacity to assess liquidity
1109+ /// on the most significant network routes.
1110+ ///
1111+ /// # Parameters
1112+ /// * `probing_interval_secs` - Seconds between probing cycles
1113+ /// * `probing_amount_msat` - Amount in milli-satoshis per probe
1114+ /// * `max_targets_per_cycle` - Maximum peers to probe each cycle
1115+ /// * `target_cache_reuse_limit` - Number of cycles to reuse targets before refreshing.
1116+ /// Acts as a cache: targets are reloaded from the network graph only after this many cycles,
1117+ /// reducing overhead while adapting to network changes.
1118+ pub fn set_probing_service_with_high_capacity_strategy (
1119+ & self , probing_interval_secs : u64 , probing_amount_msat : u64 , max_targets_per_cycle : usize ,
1120+ target_cache_reuse_limit : usize ,
1121+ ) {
1122+ self . inner . write ( ) . unwrap ( ) . set_probing_service_with_high_capacity_strategy (
1123+ probing_interval_secs,
1124+ probing_amount_msat,
1125+ max_targets_per_cycle,
1126+ target_cache_reuse_limit,
1127+ ) ;
1128+ }
1129+
10631130 /// Sets the used storage directory path.
10641131 pub fn set_storage_dir_path ( & self , storage_dir_path : String ) {
10651132 self . inner . write ( ) . unwrap ( ) . set_storage_dir_path ( storage_dir_path) ;
@@ -1854,6 +1921,14 @@ fn build_with_store_internal(
18541921 let probing_service = if let Some ( pro_ser) = probing_service_config {
18551922 let strategy: Arc < dyn ProbingStrategy + Send + Sync > = match & pro_ser. strategy {
18561923 ProbingStrategyConfig :: Custom { strategy } => Arc :: clone ( strategy) ,
1924+ ProbingStrategyConfig :: HighCapacity {
1925+ max_targets_per_cycle : max_targets,
1926+ target_cache_reuse_limit : max_reloads,
1927+ } => Arc :: new ( HighCapacityStrategy :: new (
1928+ Arc :: clone ( & network_graph) ,
1929+ * max_targets,
1930+ * max_reloads,
1931+ ) ) ,
18571932 } ;
18581933 Some ( Arc :: new ( ProbingService :: new (
18591934 pro_ser. probing_interval_secs ,
0 commit comments