@@ -44,6 +44,7 @@ use lightning_rapid_gossip_sync::RapidGossipSync;
4444
4545use core:: ops:: Deref ;
4646use core:: time:: Duration ;
47+ use std:: marker:: PhantomData ;
4748
4849#[ cfg( feature = "std" ) ]
4950use core:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -57,9 +58,6 @@ use std::time::Instant;
5758#[ cfg( not( feature = "std" ) ) ]
5859use alloc:: boxed:: Box ;
5960
60- #[ cfg( feature = "std" ) ]
61- use std:: marker:: PhantomData ;
62-
6361/// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
6462/// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
6563/// responsibilities are:
@@ -754,7 +752,7 @@ pub async fn process_events_async<
754752 Sleeper : Fn ( Duration ) -> SleepFuture ,
755753 FetchTime : Fn ( ) -> Option < Duration > ,
756754> (
757- config : BackgroundProcessorConfig <
755+ # [ rustfmt :: skip ] config : BackgroundProcessorConfig <
758756 ' a ,
759757 UL ,
760758 CF ,
@@ -1043,23 +1041,6 @@ impl BackgroundProcessor {
10431041 /// This method is functionally equivalent to [`BackgroundProcessor::start`], but takes a configuration
10441042 /// object instead of individual parameters.
10451043 ///
1046- /// # Example
1047- /// ```
1048- /// # use lightning_background_processor::*;
1049- /// let mut builder = BackgroundProcessorConfigBuilder::new(
1050- /// persister,
1051- /// event_handler,
1052- /// chain_monitor,
1053- /// channel_manager,
1054- /// gossip_sync,
1055- /// peer_manager,
1056- /// logger
1057- /// );
1058- /// builder.with_onion_messenger(messenger);
1059- /// .with_scorer(scorer);
1060- /// let config = builder.build();
1061- /// let bg_processor = BackgroundProcessor::from_config(config);
1062- /// ```
10631044 pub fn from_config <
10641045 ' a ,
10651046 UL : ' static + Deref + Send + Sync ,
@@ -1083,7 +1064,7 @@ impl BackgroundProcessor {
10831064 S : ' static + Deref < Target = SC > + Send + Sync ,
10841065 SC : for < ' b > WriteableScore < ' b > ,
10851066 > (
1086- config : BackgroundProcessorConfig <
1067+ # [ rustfmt :: skip ] config : BackgroundProcessorConfig <
10871068 ' a ,
10881069 UL ,
10891070 CF ,
@@ -1193,32 +1174,6 @@ impl BackgroundProcessor {
11931174/// * Running the async variant of the background processor via [`process_events_async`]"
11941175) ]
11951176///
1196- /// # Example
1197- /// ```
1198- /// # use lightning_background_processor::*;
1199- /// let mut builder = BackgroundProcessorConfigBuilder::new(
1200- /// persister,
1201- /// event_handler,
1202- /// chain_monitor,
1203- /// channel_manager,
1204- /// gossip_sync,
1205- /// peer_manager,
1206- /// logger
1207- /// );
1208- /// builder.with_onion_messenger(messenger); // Optional
1209- /// .with_scorer(scorer); // Optional
1210- /// let config = builder.build();
1211- ///
1212- /// // Use with BackgroundProcessor
1213- /// let processor = BackgroundProcessor::from_config(config);
1214- ///
1215- #[ cfg_attr(
1216- feature = "futures" ,
1217- doc = "
1218- /// // Or use with async processing
1219- /// process_events_async(config, sleeper, mobile_interruptable_platform, fetch_time).await?;"
1220- ) ]
1221- /// ```
12221177#[ cfg( any( feature = "std" , feature = "futures" ) ) ]
12231178pub struct BackgroundProcessorConfig <
12241179 ' a ,
@@ -1230,7 +1185,8 @@ pub struct BackgroundProcessorConfig<
12301185 L : ' static + Deref + Send + Sync ,
12311186 P : ' static + Deref + Send + Sync ,
12321187 #[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1233- #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1188+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1189+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
12341190 PS : ' static + Deref + Send ,
12351191 M : ' static
12361192 + Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1272,7 +1228,7 @@ pub struct BackgroundProcessorConfig<
12721228/// This builder provides a flexible and type-safe way to construct a [`BackgroundProcessorConfig`]
12731229/// with optional components like `onion_messenger` and `scorer`. It helps avoid specifying
12741230/// concrete types for components that aren't being used.
1275- #[ cfg( feature = "std" ) ]
1231+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
12761232pub struct BackgroundProcessorConfigBuilder <
12771233 ' a ,
12781234 UL : ' static + Deref + Send + Sync ,
@@ -1282,7 +1238,9 @@ pub struct BackgroundProcessorConfigBuilder<
12821238 G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
12831239 L : ' static + Deref + Send + Sync ,
12841240 P : ' static + Deref + Send + Sync ,
1285- EH : ' static + EventHandler + Send ,
1241+ #[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1242+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1243+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
12861244 PS : ' static + Deref + Send ,
12871245 M : ' static
12881246 + Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1319,7 +1277,7 @@ pub struct BackgroundProcessorConfigBuilder<
13191277 _phantom : PhantomData < ( & ' a ( ) , CF , T , F , P ) > ,
13201278}
13211279
1322- #[ cfg( feature = "std" ) ]
1280+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
13231281impl <
13241282 ' a ,
13251283 UL : ' static + Deref + Send + Sync ,
@@ -1329,7 +1287,9 @@ impl<
13291287 G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
13301288 L : ' static + Deref + Send + Sync ,
13311289 P : ' static + Deref + Send + Sync ,
1332- EH : ' static + EventHandler + Send ,
1290+ #[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1291+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1292+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
13331293 PS : ' static + Deref + Send ,
13341294 M : ' static
13351295 + Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -3196,7 +3156,7 @@ mod tests {
31963156 // Check scorer is persisted
31973157 let filepath =
31983158 get_full_filepath ( format ! ( "{}_persister_0" , & persist_dir) , "scorer" . to_string ( ) ) ;
3199- check_persisted_data ! ( nodes[ 0 ] . scorer, filepath) ;
3159+ check_persisted_data ! ( nodes[ 0 ] . scorer, filepath. clone ( ) ) ;
32003160
32013161 if !std:: thread:: panicking ( ) {
32023162 bg_processor. stop ( ) . unwrap ( ) ;
0 commit comments