/// * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
/// writing it to disk/backups by invoking the callback given to it at startup.
/// ChannelManager persistence should be done in the background.
-/// * Calling `ChannelManager::timer_tick_occurred()` every minute (can be done in the
+/// * Calling `ChannelManager::timer_tick_occurred()` and
+/// `PeerManager::timer_tick_occurred()` every minute (can be done in the
/// background).
///
/// Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
}
#[cfg(not(test))]
-const CHAN_FRESHNESS_TIMER: u64 = 60;
+const FRESHNESS_TIMER: u64 = 60;
#[cfg(test)]
-const CHAN_FRESHNESS_TIMER: u64 = 1;
+const FRESHNESS_TIMER: u64 = 1;
impl BackgroundProcessor {
/// Start a background thread that takes care of responsibilities enumerated in the top-level
log_trace!(logger, "Terminating background processor.");
return Ok(());
}
- if current_time.elapsed().as_secs() > CHAN_FRESHNESS_TIMER {
- log_trace!(logger, "Calling manager's timer_tick_occurred");
+ if current_time.elapsed().as_secs() > FRESHNESS_TIMER {
+ log_trace!(logger, "Calling ChannelManager's and PeerManager's timer_tick_occurred");
channel_manager.timer_tick_occurred();
+ peer_manager.timer_tick_occurred();
current_time = Instant::now();
}
}
#[test]
fn test_timer_tick_called() {
- // Test that ChannelManager's `timer_tick_occurred` is called every
- // `CHAN_FRESHNESS_TIMER`.
- let nodes = create_nodes(1, "test_chan_freshness_called".to_string());
+ // Test that ChannelManager's and PeerManager's `timer_tick_occurred` is called every
+ // `FRESHNESS_TIMER`.
+ let nodes = create_nodes(1, "test_timer_tick_called".to_string());
let data_dir = nodes[0].persister.get_data_dir();
let callback = move |node: &ChannelManager<InMemorySigner, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
let bg_processor = BackgroundProcessor::start(callback, nodes[0].node.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone());
loop {
let log_entries = nodes[0].logger.lines.lock().unwrap();
- let desired_log = "Calling manager's timer_tick_occurred".to_string();
+ let desired_log = "Calling ChannelManager's and PeerManager's timer_tick_occurred".to_string();
if log_entries.get(&("lightning_background_processor".to_string(), desired_log)).is_some() {
break
}