Skip to content

Commit

Permalink
f confirm/broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Nov 8, 2024
1 parent 784a0b7 commit e9cde47
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// This file is Copyright its original authors, visible in version control history.
//
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
Expand Down Expand Up @@ -256,68 +255,6 @@ impl Node {
.continuously_sync_wallets(stop_sync_receiver, sync_cman, sync_cmon, sync_sweeper)
.await;
});
let sync_logger = Arc::clone(&self.logger);
let sync_payjoin = &self.payjoin_handler.as_ref();
let sync_payjoin = sync_payjoin.map(Arc::clone);
let sync_wallet_timestamp = Arc::clone(&self.latest_wallet_sync_timestamp);
let sync_monitor_archival_height = Arc::clone(&self.latest_channel_monitor_archival_height);
let mut stop_sync = self.stop_sender.subscribe();
let wallet_sync_interval_secs =
self.config.wallet_sync_interval_secs.max(WALLET_SYNC_INTERVAL_MINIMUM_SECS);
runtime.spawn(async move {
let mut wallet_sync_interval =
tokio::time::interval(Duration::from_secs(wallet_sync_interval_secs));
wallet_sync_interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
loop {
tokio::select! {
_ = stop_sync.changed() => {
log_trace!(
sync_logger,
"Stopping background syncing Lightning wallet.",
);
return;
}
_ = wallet_sync_interval.tick() => {
let mut confirmables = vec![
&*sync_cman as &(dyn Confirm + Sync + Send),
&*sync_cmon as &(dyn Confirm + Sync + Send),
&*sync_sweeper as &(dyn Confirm + Sync + Send),
];
if let Some(sync_payjoin) = sync_payjoin.as_ref() {
confirmables.push(sync_payjoin.as_ref() as &(dyn Confirm + Sync + Send));
}
let now = Instant::now();
let timeout_fut = tokio::time::timeout(Duration::from_secs(LDK_WALLET_SYNC_TIMEOUT_SECS), tx_sync.sync(confirmables));
match timeout_fut.await {
Ok(res) => match res {
Ok(()) => {
log_trace!(
sync_logger,
"Background sync of Lightning wallet finished in {}ms.",
now.elapsed().as_millis()
);
let unix_time_secs_opt =
SystemTime::now().duration_since(UNIX_EPOCH).ok().map(|d| d.as_secs());
*sync_wallet_timestamp.write().unwrap() = unix_time_secs_opt;

periodically_archive_fully_resolved_monitors(
Arc::clone(&archive_cman),
Arc::clone(&archive_cmon),
Arc::clone(&sync_monitor_archival_height)
);
}
Err(e) => {
log_error!(sync_logger, "Background sync of Lightning wallet failed: {}", e)
}
}
Err(e) => {
log_error!(sync_logger, "Background sync of Lightning wallet timed out: {}", e)
}
}
}
}
}
});

if self.gossip_source.is_rgs() {
let gossip_source = Arc::clone(&self.gossip_source);
Expand Down

0 comments on commit e9cde47

Please sign in to comment.