@@ -122,8 +122,8 @@ pub use builder::BuildError;
122
122
pub use builder:: NodeBuilder as Builder ;
123
123
124
124
use config:: {
125
- NODE_ANN_BCAST_INTERVAL , PEER_RECONNECTION_INTERVAL , RGS_SYNC_INTERVAL ,
126
- WALLET_SYNC_INTERVAL_MINIMUM_SECS ,
125
+ LDK_WALLET_SYNC_TIMEOUT_SECS , NODE_ANN_BCAST_INTERVAL , PEER_RECONNECTION_INTERVAL ,
126
+ RGS_SYNC_INTERVAL , WALLET_SYNC_INTERVAL_MINIMUM_SECS ,
127
127
} ;
128
128
use connection:: ConnectionManager ;
129
129
use event:: { EventHandler , EventQueue } ;
@@ -366,19 +366,25 @@ impl Node {
366
366
& * sync_sweeper as & ( dyn Confirm + Sync + Send ) ,
367
367
] ;
368
368
let now = Instant :: now( ) ;
369
- match tx_sync. sync( confirmables) . await {
370
- Ok ( ( ) ) => {
371
- log_trace!(
372
- sync_logger,
373
- "Background sync of Lightning wallet finished in {}ms." ,
374
- now. elapsed( ) . as_millis( )
375
- ) ;
376
- let unix_time_secs_opt =
377
- SystemTime :: now( ) . duration_since( UNIX_EPOCH ) . ok( ) . map( |d| d. as_secs( ) ) ;
378
- * sync_wallet_timestamp. write( ) . unwrap( ) = unix_time_secs_opt;
369
+ let timeout_fut = tokio:: time:: timeout( Duration :: from_secs( LDK_WALLET_SYNC_TIMEOUT_SECS ) , tx_sync. sync( confirmables) ) ;
370
+ match timeout_fut. await {
371
+ Ok ( res) => match res {
372
+ Ok ( ( ) ) => {
373
+ log_trace!(
374
+ sync_logger,
375
+ "Background sync of Lightning wallet finished in {}ms." ,
376
+ now. elapsed( ) . as_millis( )
377
+ ) ;
378
+ let unix_time_secs_opt =
379
+ SystemTime :: now( ) . duration_since( UNIX_EPOCH ) . ok( ) . map( |d| d. as_secs( ) ) ;
380
+ * sync_wallet_timestamp. write( ) . unwrap( ) = unix_time_secs_opt;
381
+ }
382
+ Err ( e) => {
383
+ log_error!( sync_logger, "Background sync of Lightning wallet failed: {}" , e)
384
+ }
379
385
}
380
386
Err ( e) => {
381
- log_error!( sync_logger, "Background sync of Lightning wallet failed : {}" , e)
387
+ log_error!( sync_logger, "Background sync of Lightning wallet timed out : {}" , e)
382
388
}
383
389
}
384
390
}
0 commit comments