@@ -763,7 +763,7 @@ pub async fn process_events_async<
763
763
G ,
764
764
L ,
765
765
P ,
766
- EH ,
766
+ EventHandler ,
767
767
PS ,
768
768
M ,
769
769
CM ,
@@ -818,31 +818,41 @@ where
818
818
event_handler ( event) . await
819
819
} )
820
820
} ;
821
+ // We should extract these out of config because the macro expects individual arguments
822
+ let persister = config. persister ;
823
+ let chain_monitor = config. chain_monitor ;
824
+ let channel_manager = config. channel_manager ;
825
+ let onion_messenger = config. onion_messenger ;
826
+ let peer_manager = config. peer_manager ;
827
+ let gossip_sync = config. gossip_sync ;
828
+ let logger = config. logger ;
829
+ let scorer = config. scorer ;
830
+
821
831
define_run_body ! (
822
- config . persister,
823
- config . chain_monitor,
824
- config . chain_monitor. process_pending_events_async( async_event_handler) . await ,
825
- config . channel_manager,
826
- config . channel_manager. get_cm( ) . process_pending_events_async( async_event_handler) . await ,
827
- config . onion_messenger,
828
- if let Some ( om) = & config . onion_messenger {
832
+ persister,
833
+ chain_monitor,
834
+ chain_monitor. process_pending_events_async( async_event_handler) . await ,
835
+ channel_manager,
836
+ channel_manager. get_cm( ) . process_pending_events_async( async_event_handler) . await ,
837
+ onion_messenger,
838
+ if let Some ( om) = & onion_messenger {
829
839
om. get_om( ) . process_pending_events_async( async_event_handler) . await
830
840
} ,
831
- config . peer_manager,
832
- config . gossip_sync,
833
- config . logger,
834
- config . scorer,
841
+ peer_manager,
842
+ gossip_sync,
843
+ logger,
844
+ scorer,
835
845
should_break,
836
846
{
837
- let om_fut = if let Some ( om) = config . onion_messenger. as_ref( ) {
847
+ let om_fut = if let Some ( om) = onion_messenger. as_ref( ) {
838
848
let fut = om. get_om( ) . get_update_future( ) ;
839
849
OptionalSelector { optional_future: Some ( fut) }
840
850
} else {
841
851
OptionalSelector { optional_future: None }
842
852
} ;
843
853
let fut = Selector {
844
- a: config . channel_manager. get_cm( ) . get_event_or_persistence_needed_future( ) ,
845
- b: config . chain_monitor. get_update_future( ) ,
854
+ a: channel_manager. get_cm( ) . get_event_or_persistence_needed_future( ) ,
855
+ b: chain_monitor. get_update_future( ) ,
846
856
c: om_fut,
847
857
d: sleeper( if mobile_interruptable_platform {
848
858
Duration :: from_millis( 100 )
@@ -1209,7 +1219,7 @@ impl BackgroundProcessor {
1209
1219
/// process_events_async(config, sleeper, mobile_interruptable_platform, fetch_time).await?;"
1210
1220
) ]
1211
1221
/// ```
1212
- #[ cfg( feature = "std" ) ]
1222
+ #[ cfg( any ( feature = "std" , feature = "futures" ) ) ]
1213
1223
pub struct BackgroundProcessorConfig <
1214
1224
' a ,
1215
1225
UL : ' static + Deref + Send + Sync ,
@@ -1346,7 +1356,7 @@ where
1346
1356
PM :: Target : APeerManager + Send + Sync ,
1347
1357
{
1348
1358
/// Creates a new builder instance.
1349
- pub ( crate ) fn new (
1359
+ pub fn new (
1350
1360
persister : PS , event_handler : EH , chain_monitor : M , channel_manager : CM ,
1351
1361
gossip_sync : GossipSync < PGS , RGS , G , UL , L > , peer_manager : PM , logger : L ,
1352
1362
) -> Self {
@@ -1405,7 +1415,9 @@ impl Drop for BackgroundProcessor {
1405
1415
1406
1416
#[ cfg( all( feature = "std" , test) ) ]
1407
1417
mod tests {
1408
- use super :: { BackgroundProcessor , GossipSync , FRESHNESS_TIMER } ;
1418
+ use super :: {
1419
+ BackgroundProcessor , BackgroundProcessorConfigBuilder , GossipSync , FRESHNESS_TIMER ,
1420
+ } ;
1409
1421
use bitcoin:: constants:: { genesis_block, ChainHash } ;
1410
1422
use bitcoin:: hashes:: Hash ;
1411
1423
use bitcoin:: locktime:: absolute:: LockTime ;
@@ -3086,11 +3098,11 @@ mod tests {
3086
3098
}
3087
3099
3088
3100
#[ test]
3089
- fn test_background_processor_builder ( ) {
3101
+ fn test_background_processor_config_builder ( ) {
3090
3102
// Test that when a new channel is created, the ChannelManager needs to be re-persisted with
3091
3103
// updates. Also test that when new updates are available, the manager signals that it needs
3092
3104
// re-persistence and is successfully re-persisted.
3093
- let ( persist_dir, nodes) = create_nodes ( 2 , "test_background_processor_builder " ) ;
3105
+ let ( persist_dir, nodes) = create_nodes ( 2 , "test_background_processor_config_builder " ) ;
3094
3106
3095
3107
// Go through the channel creation process so that each node has something to persist. Since
3096
3108
// open_channel consumes events, it must complete before starting BackgroundProcessor to
@@ -3164,7 +3176,7 @@ mod tests {
3164
3176
. unwrap ( ) ;
3165
3177
3166
3178
// Check that the force-close updates are persisted
3167
- check_persisted_data ! ( nodes[ 0 ] . node, manager_path . clone( ) ) ;
3179
+ check_persisted_data ! ( nodes[ 0 ] . node, filepath . clone( ) ) ;
3168
3180
loop {
3169
3181
if !nodes[ 0 ] . node . get_event_or_persist_condvar_value ( ) {
3170
3182
break ;
0 commit comments