@@ -51,6 +51,7 @@ use lightning_liquidity::ALiquidityManager;
51
51
52
52
use core:: ops:: Deref ;
53
53
use core:: time:: Duration ;
54
+ use std:: marker:: PhantomData ;
54
55
55
56
#[ cfg( feature = "std" ) ]
56
57
use core:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -64,9 +65,6 @@ use std::time::Instant;
64
65
#[ cfg( not( feature = "std" ) ) ]
65
66
use alloc:: boxed:: Box ;
66
67
67
- #[ cfg( feature = "std" ) ]
68
- use std:: marker:: PhantomData ;
69
-
70
68
/// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
71
69
/// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
72
70
/// responsibilities are:
@@ -1115,23 +1113,6 @@ impl BackgroundProcessor {
1115
1113
/// This method is functionally equivalent to [`BackgroundProcessor::start`], but takes a configuration
1116
1114
/// object instead of individual parameters.
1117
1115
///
1118
- /// # Example
1119
- /// ```
1120
- /// # use lightning_background_processor::*;
1121
- /// let mut builder = BackgroundProcessorConfigBuilder::new(
1122
- /// persister,
1123
- /// event_handler,
1124
- /// chain_monitor,
1125
- /// channel_manager,
1126
- /// gossip_sync,
1127
- /// peer_manager,
1128
- /// logger
1129
- /// );
1130
- /// builder.with_onion_messenger(messenger);
1131
- /// .with_scorer(scorer);
1132
- /// let config = builder.build();
1133
- /// let bg_processor = BackgroundProcessor::from_config(config);
1134
- /// ```
1135
1116
pub fn from_config <
1136
1117
' a ,
1137
1118
UL : ' static + Deref + Send + Sync ,
@@ -1155,7 +1136,7 @@ impl BackgroundProcessor {
1155
1136
S : ' static + Deref < Target = SC > + Send + Sync ,
1156
1137
SC : for < ' b > WriteableScore < ' b > ,
1157
1138
> (
1158
- config : BackgroundProcessorConfig <
1139
+ # [ rustfmt :: skip ] config : BackgroundProcessorConfig <
1159
1140
' a ,
1160
1141
UL ,
1161
1142
CF ,
@@ -1265,32 +1246,6 @@ impl BackgroundProcessor {
1265
1246
/// * Running the async variant of the background processor via [`process_events_async`]"
1266
1247
) ]
1267
1248
///
1268
- /// # Example
1269
- /// ```
1270
- /// # use lightning_background_processor::*;
1271
- /// let mut builder = BackgroundProcessorConfigBuilder::new(
1272
- /// persister,
1273
- /// event_handler,
1274
- /// chain_monitor,
1275
- /// channel_manager,
1276
- /// gossip_sync,
1277
- /// peer_manager,
1278
- /// logger
1279
- /// );
1280
- /// builder.with_onion_messenger(messenger); // Optional
1281
- /// .with_scorer(scorer); // Optional
1282
- /// let config = builder.build();
1283
- ///
1284
- /// // Use with BackgroundProcessor
1285
- /// let processor = BackgroundProcessor::from_config(config);
1286
- ///
1287
- #[ cfg_attr(
1288
- feature = "futures" ,
1289
- doc = "
1290
- /// // Or use with async processing
1291
- /// process_events_async(config, sleeper, mobile_interruptable_platform, fetch_time).await?;"
1292
- ) ]
1293
- /// ```
1294
1249
#[ cfg( any( feature = "std" , feature = "futures" ) ) ]
1295
1250
pub struct BackgroundProcessorConfig <
1296
1251
' a ,
@@ -1302,7 +1257,8 @@ pub struct BackgroundProcessorConfig<
1302
1257
L : ' static + Deref + Send + Sync ,
1303
1258
P : ' static + Deref + Send + Sync ,
1304
1259
#[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1305
- #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1260
+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1261
+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
1306
1262
PS : ' static + Deref + Send ,
1307
1263
M : ' static
1308
1264
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1344,7 +1300,7 @@ pub struct BackgroundProcessorConfig<
1344
1300
/// This builder provides a flexible and type-safe way to construct a [`BackgroundProcessorConfig`]
1345
1301
/// with optional components like `onion_messenger` and `scorer`. It helps avoid specifying
1346
1302
/// concrete types for components that aren't being used.
1347
- #[ cfg( feature = "std" ) ]
1303
+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
1348
1304
pub struct BackgroundProcessorConfigBuilder <
1349
1305
' a ,
1350
1306
UL : ' static + Deref + Send + Sync ,
@@ -1354,7 +1310,9 @@ pub struct BackgroundProcessorConfigBuilder<
1354
1310
G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
1355
1311
L : ' static + Deref + Send + Sync ,
1356
1312
P : ' static + Deref + Send + Sync ,
1357
- EH : ' static + EventHandler + Send ,
1313
+ #[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1314
+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1315
+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
1358
1316
PS : ' static + Deref + Send ,
1359
1317
M : ' static
1360
1318
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -1391,7 +1349,7 @@ pub struct BackgroundProcessorConfigBuilder<
1391
1349
_phantom : PhantomData < ( & ' a ( ) , CF , T , F , P ) > ,
1392
1350
}
1393
1351
1394
- #[ cfg( feature = "std" ) ]
1352
+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
1395
1353
impl <
1396
1354
' a ,
1397
1355
UL : ' static + Deref + Send + Sync ,
@@ -1401,7 +1359,9 @@ impl<
1401
1359
G : ' static + Deref < Target = NetworkGraph < L > > + Send + Sync ,
1402
1360
L : ' static + Deref + Send + Sync ,
1403
1361
P : ' static + Deref + Send + Sync ,
1404
- EH : ' static + EventHandler + Send ,
1362
+ #[ cfg( feature = "std" ) ] EH : ' static + EventHandler + Send ,
1363
+ #[ cfg( feature = "futures" ) ] EventHandlerFuture : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1364
+ #[ cfg( feature = "futures" ) ] EH : ' static + Fn ( Event ) -> EventHandlerFuture ,
1405
1365
PS : ' static + Deref + Send ,
1406
1366
M : ' static
1407
1367
+ Deref < Target = ChainMonitor < <CM :: Target as AChannelManager >:: Signer , CF , T , F , L , P > >
@@ -3319,7 +3279,7 @@ mod tests {
3319
3279
// Check scorer is persisted
3320
3280
let filepath =
3321
3281
get_full_filepath ( format ! ( "{}_persister_0" , & persist_dir) , "scorer" . to_string ( ) ) ;
3322
- check_persisted_data ! ( nodes[ 0 ] . scorer, filepath) ;
3282
+ check_persisted_data ! ( nodes[ 0 ] . scorer, filepath. clone ( ) ) ;
3323
3283
3324
3284
if !std:: thread:: panicking ( ) {
3325
3285
bg_processor. stop ( ) . unwrap ( ) ;
0 commit comments