@@ -44,6 +44,7 @@ use lightning_rapid_gossip_sync::RapidGossipSync;
44
44
45
45
use core:: ops:: Deref ;
46
46
use core:: time:: Duration ;
47
+ use std:: marker:: PhantomData ;
47
48
48
49
#[ cfg( feature = "std" ) ]
49
50
use core:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -57,9 +58,6 @@ use std::time::Instant;
57
58
#[ cfg( not( feature = "std" ) ) ]
58
59
use alloc:: boxed:: Box ;
59
60
60
- #[ cfg( feature = "std" ) ]
61
- use std:: marker:: PhantomData ;
62
-
63
61
/// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
64
62
/// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
65
63
/// responsibilities are:
@@ -754,7 +752,7 @@ pub async fn process_events_async<
754
752
Sleeper : Fn ( Duration ) -> SleepFuture ,
755
753
FetchTime : Fn ( ) -> Option < Duration > ,
756
754
> (
757
- config : BackgroundProcessorConfig <
755
+ # [ rustfmt :: skip ] config : BackgroundProcessorConfig <
758
756
' a ,
759
757
UL ,
760
758
CF ,
@@ -1043,23 +1041,6 @@ impl BackgroundProcessor {
1043
1041
/// This method is functionally equivalent to [`BackgroundProcessor::start`], but takes a configuration
1044
1042
/// object instead of individual parameters.
1045
1043
///
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
- /// ```
1063
1044
pub fn from_config <
1064
1045
' a ,
1065
1046
UL : ' static + Deref + Send + Sync ,
@@ -1083,7 +1064,7 @@ impl BackgroundProcessor {
1083
1064
S : ' static + Deref < Target = SC > + Send + Sync ,
1084
1065
SC : for < ' b > WriteableScore < ' b > ,
1085
1066
> (
1086
- config : BackgroundProcessorConfig <
1067
+ # [ rustfmt :: skip ] config : BackgroundProcessorConfig <
1087
1068
' a ,
1088
1069
UL ,
1089
1070
CF ,
@@ -1193,32 +1174,6 @@ impl BackgroundProcessor {
1193
1174
/// * Running the async variant of the background processor via [`process_events_async`]"
1194
1175
) ]
1195
1176
///
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
- /// ```
1222
1177
#[ cfg( any( feature = "std" , feature = "futures" ) ) ]
1223
1178
pub struct BackgroundProcessorConfig <
1224
1179
' a ,
@@ -1230,7 +1185,8 @@ pub struct BackgroundProcessorConfig<
1230
1185
L : ' static + Deref + Send + Sync ,
1231
1186
P : ' static + Deref + Send + Sync ,
1232
1187
#[ 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 ,
1234
1190
PS : ' static + Deref + Send ,
1235
1191
M : ' static
1236
1192
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1272,7 +1228,7 @@ pub struct BackgroundProcessorConfig<
1272
1228
/// This builder provides a flexible and type-safe way to construct a [`BackgroundProcessorConfig`]
1273
1229
/// with optional components like `onion_messenger` and `scorer`. It helps avoid specifying
1274
1230
/// concrete types for components that aren't being used.
1275
- #[ cfg( feature = "std" ) ]
1231
+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
1276
1232
pub struct BackgroundProcessorConfigBuilder <
1277
1233
' a ,
1278
1234
UL : ' static + Deref + Send + Sync ,
@@ -1282,7 +1238,9 @@ pub struct BackgroundProcessorConfigBuilder<
1282
1238
G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
1283
1239
L : ' static + Deref + Send + Sync ,
1284
1240
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 ,
1286
1244
PS : ' static + Deref + Send ,
1287
1245
M : ' static
1288
1246
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1319,7 +1277,7 @@ pub struct BackgroundProcessorConfigBuilder<
1319
1277
_phantom : PhantomData < ( & ' a ( ) , CF , T , F , P ) > ,
1320
1278
}
1321
1279
1322
- #[ cfg( feature = "std" ) ]
1280
+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
1323
1281
impl <
1324
1282
' a ,
1325
1283
UL : ' static + Deref + Send + Sync ,
@@ -1329,7 +1287,9 @@ impl<
1329
1287
G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
1330
1288
L : ' static + Deref + Send + Sync ,
1331
1289
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 ,
1333
1293
PS : ' static + Deref + Send ,
1334
1294
M : ' static
1335
1295
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -3196,7 +3156,7 @@ mod tests {
3196
3156
// Check scorer is persisted
3197
3157
let filepath =
3198
3158
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 ( ) ) ;
3200
3160
3201
3161
if !std:: thread:: panicking ( ) {
3202
3162
bg_processor. stop ( ) . unwrap ( ) ;
0 commit comments