@@ -123,7 +123,7 @@ pub use builder::BuildError;
123
123
pub use builder:: NodeBuilder as Builder ;
124
124
125
125
use config:: {
126
- NODE_ANN_BCAST_INTERVAL , PEER_RECONNECTION_INTERVAL ,
126
+ LDK_WALLET_SYNC_TIMEOUT_SECS , NODE_ANN_BCAST_INTERVAL , PEER_RECONNECTION_INTERVAL ,
127
127
RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL , RGS_SYNC_INTERVAL ,
128
128
WALLET_SYNC_INTERVAL_MINIMUM_SECS ,
129
129
} ;
@@ -373,25 +373,31 @@ impl Node {
373
373
& * sync_sweeper as & ( dyn Confirm + Sync + Send ) ,
374
374
] ;
375
375
let now = Instant :: now( ) ;
376
- match tx_sync. sync( confirmables) . await {
377
- Ok ( ( ) ) => {
378
- log_trace!(
379
- sync_logger,
380
- "Background sync of Lightning wallet finished in {}ms." ,
381
- now. elapsed( ) . as_millis( )
382
- ) ;
383
- let unix_time_secs_opt =
384
- SystemTime :: now( ) . duration_since( UNIX_EPOCH ) . ok( ) . map( |d| d. as_secs( ) ) ;
385
- * sync_wallet_timestamp. write( ) . unwrap( ) = unix_time_secs_opt;
386
-
387
- periodically_archive_fully_resolved_monitors(
388
- Arc :: clone( & archive_cman) ,
389
- Arc :: clone( & archive_cmon) ,
390
- Arc :: clone( & sync_monitor_archival_height)
391
- ) ;
376
+ let timeout_fut = tokio:: time:: timeout( Duration :: from_secs( LDK_WALLET_SYNC_TIMEOUT_SECS ) , tx_sync. sync( confirmables) ) ;
377
+ match timeout_fut. await {
378
+ Ok ( res) => match res {
379
+ Ok ( ( ) ) => {
380
+ log_trace!(
381
+ sync_logger,
382
+ "Background sync of Lightning wallet finished in {}ms." ,
383
+ now. elapsed( ) . as_millis( )
384
+ ) ;
385
+ let unix_time_secs_opt =
386
+ SystemTime :: now( ) . duration_since( UNIX_EPOCH ) . ok( ) . map( |d| d. as_secs( ) ) ;
387
+ * sync_wallet_timestamp. write( ) . unwrap( ) = unix_time_secs_opt;
388
+
389
+ periodically_archive_fully_resolved_monitors(
390
+ Arc :: clone( & archive_cman) ,
391
+ Arc :: clone( & archive_cmon) ,
392
+ Arc :: clone( & sync_monitor_archival_height)
393
+ ) ;
394
+ }
395
+ Err ( e) => {
396
+ log_error!( sync_logger, "Background sync of Lightning wallet failed: {}" , e)
397
+ }
392
398
}
393
399
Err ( e) => {
394
- log_error!( sync_logger, "Background sync of Lightning wallet failed : {}" , e)
400
+ log_error!( sync_logger, "Background sync of Lightning wallet timed out : {}" , e)
395
401
}
396
402
}
397
403
}
0 commit comments