@@ -66,6 +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 ;
6970use crate :: runtime:: Runtime ;
7071use crate :: tx_broadcaster:: TransactionBroadcaster ;
7172use crate :: types:: {
@@ -129,6 +130,16 @@ struct LiquiditySourceConfig {
129130 lsps2_service : Option < LSPS2ServiceConfig > ,
130131}
131132
133+ #[ derive( Debug , Clone ) ]
134+ struct ProbingServiceConfig {
135+ /// Time in seconds between consecutive probing attempts.
136+ probing_interval_secs : u64 ,
137+ /// Maximum number of distinct targets to probe concurrently.
138+ max_probing_targets : usize ,
139+ /// Amount in milli-satoshis used for each probe.
140+ probing_amount_msat : u64 ,
141+ }
142+
132143#[ derive( Clone ) ]
133144enum LogWriterConfig {
134145 File { log_file_path : Option < String > , max_log_level : Option < LogLevel > } ,
@@ -253,6 +264,7 @@ pub struct NodeBuilder {
253264 async_payments_role : Option < AsyncPaymentsRole > ,
254265 runtime_handle : Option < tokio:: runtime:: Handle > ,
255266 pathfinding_scores_sync_config : Option < PathfindingScoresSyncConfig > ,
267+ probing_service_config : Option < ProbingServiceConfig > ,
256268}
257269
258270impl NodeBuilder {
@@ -271,6 +283,7 @@ impl NodeBuilder {
271283 let log_writer_config = None ;
272284 let runtime_handle = None ;
273285 let pathfinding_scores_sync_config = None ;
286+ let probing_service_config = None ;
274287 Self {
275288 config,
276289 entropy_source_config,
@@ -281,6 +294,7 @@ impl NodeBuilder {
281294 runtime_handle,
282295 async_payments_role : None ,
283296 pathfinding_scores_sync_config,
297+ probing_service_config,
284298 }
285299 }
286300
@@ -488,6 +502,23 @@ impl NodeBuilder {
488502 self
489503 }
490504
505+ /// Configures the probing service used to evaluate channel liquidity by sending
506+ /// pre-flight probes to peers and routes.
507+ ///
508+ /// * `probing_interval_secs` - Time in seconds between consecutive probing attempts.
509+ /// * `max_probing_targets` - Maximum number of distinct targets to probe concurrently.
510+ /// * `probing_amount_msat` - Amount in milli-satoshis used for each probe.
511+ pub fn set_probing_service_config (
512+ & mut self , probing_interval_secs : u64 , max_probing_targets : usize , probing_amount_msat : u64 ,
513+ ) -> & mut Self {
514+ self . probing_service_config = Some ( ProbingServiceConfig {
515+ probing_interval_secs,
516+ max_probing_targets,
517+ probing_amount_msat,
518+ } ) ;
519+ self
520+ }
521+
491522 /// Sets the used storage directory path.
492523 pub fn set_storage_dir_path ( & mut self , storage_dir_path : String ) -> & mut Self {
493524 self . config . storage_dir_path = storage_dir_path;
@@ -744,6 +775,7 @@ impl NodeBuilder {
744775 runtime,
745776 logger,
746777 Arc :: new ( vss_store) ,
778+ self . probing_service_config . as_ref ( ) ,
747779 )
748780 }
749781
@@ -778,6 +810,7 @@ impl NodeBuilder {
778810 runtime,
779811 logger,
780812 kv_store,
813+ self . probing_service_config . as_ref ( ) ,
781814 )
782815 }
783816}
@@ -982,6 +1015,17 @@ impl ArcedNodeBuilder {
9821015 self . inner . write ( ) . unwrap ( ) . set_storage_dir_path ( storage_dir_path) ;
9831016 }
9841017
1018+ // Sets the probing service used to evaluate channel liquidity by sending
1019+ pub fn set_probing_service_config (
1020+ & self , probing_interval_secs : u64 , max_probing_targets : usize , probing_amount_msat : u64 ,
1021+ ) {
1022+ self . inner . write ( ) . unwrap ( ) . set_probing_service_config (
1023+ probing_interval_secs,
1024+ max_probing_targets,
1025+ probing_amount_msat,
1026+ ) ;
1027+ }
1028+
9851029 /// Configures the [`Node`] instance to write logs to the filesystem.
9861030 ///
9871031 /// The `log_file_path` defaults to [`DEFAULT_LOG_FILENAME`] in the configured
@@ -1142,6 +1186,7 @@ fn build_with_store_internal(
11421186 pathfinding_scores_sync_config : Option < & PathfindingScoresSyncConfig > ,
11431187 async_payments_role : Option < AsyncPaymentsRole > , seed_bytes : [ u8 ; 64 ] , runtime : Arc < Runtime > ,
11441188 logger : Arc < Logger > , kv_store : Arc < DynStore > ,
1189+ probing_service_config : Option < & ProbingServiceConfig > ,
11451190) -> Result < Node , BuildError > {
11461191 optionally_install_rustls_cryptoprovider ( ) ;
11471192
@@ -1760,6 +1805,23 @@ fn build_with_store_internal(
17601805
17611806 let pathfinding_scores_sync_url = pathfinding_scores_sync_config. map ( |c| c. url . clone ( ) ) ;
17621807
1808+ let probing_service = if let Some ( pro_ser) = probing_service_config {
1809+ Some ( Arc :: new ( ProbingService :: new (
1810+ pro_ser. probing_interval_secs ,
1811+ pro_ser. max_probing_targets ,
1812+ pro_ser. probing_amount_msat ,
1813+ Arc :: clone ( & config) ,
1814+ Arc :: clone ( & logger) ,
1815+ Arc :: clone ( & channel_manager) ,
1816+ Arc :: clone ( & keys_manager) ,
1817+ Arc :: clone ( & is_running) ,
1818+ Arc :: clone ( & payment_store) ,
1819+ Arc :: clone ( & network_graph) ,
1820+ ) ) )
1821+ } else {
1822+ None
1823+ } ;
1824+
17631825 Ok ( Node {
17641826 runtime,
17651827 stop_sender,
@@ -1790,6 +1852,7 @@ fn build_with_store_internal(
17901852 node_metrics,
17911853 om_mailbox,
17921854 async_payments_role,
1855+ probing_service,
17931856 } )
17941857}
17951858
0 commit comments