Skip to content

Commit 59d91f5

Browse files
committed
Call ChainMonitor::rebroadcast_pending_claims on FRESHNESS_TIMER tick
This will prompt monitors to rebroadcast/fee-bump their pending claims on a force-closed channel roughly every minute.
1 parent ecb3b25 commit 59d91f5

File tree

1 file changed

+13
-8
lines changed
  • lightning-background-processor/src

1 file changed

+13
-8
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ use alloc::vec::Vec;
6464
/// * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so,
6565
/// writing it to disk/backups by invoking the callback given to it at startup.
6666
/// [`ChannelManager`] persistence should be done in the background.
67-
/// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
68-
/// at the appropriate intervals.
67+
/// * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`]
68+
/// and [`PeerManager::timer_tick_occurred`] at the appropriate intervals.
6969
/// * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a
7070
/// [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]).
7171
///
@@ -314,6 +314,8 @@ macro_rules! define_run_body {
314314
if $timer_elapsed(&mut last_freshness_call, FRESHNESS_TIMER) {
315315
log_trace!($logger, "Calling ChannelManager's timer_tick_occurred");
316316
$channel_manager.timer_tick_occurred();
317+
log_trace!($logger, "Calling ChainMonitor's rebroadcast_pending_claims");
318+
$chain_monitor.rebroadcast_pending_claims();
317319
last_freshness_call = $get_timer(FRESHNESS_TIMER);
318320
}
319321
if await_slow {
@@ -1189,19 +1191,22 @@ mod tests {
11891191

11901192
#[test]
11911193
fn test_timer_tick_called() {
1192-
// Test that ChannelManager's and PeerManager's `timer_tick_occurred` is called every
1193-
// `FRESHNESS_TIMER`.
1194+
// Test that `ChannelManager::timer_tick_occurred` and
1195+
// `ChainMonitor::rebroadcast_pending_claims` is called every `FRESHNESS_TIMER` and
1196+
// `PeerManager::timer_tick_occurred` every `PING_TIMER`.
11941197
let nodes = create_nodes(1, "test_timer_tick_called".to_string());
11951198
let data_dir = nodes[0].persister.get_data_dir();
11961199
let persister = Arc::new(Persister::new(data_dir));
11971200
let event_handler = |_: _| {};
11981201
let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].no_gossip_sync(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()));
11991202
loop {
12001203
let log_entries = nodes[0].logger.lines.lock().unwrap();
1201-
let desired_log = "Calling ChannelManager's timer_tick_occurred".to_string();
1202-
let second_desired_log = "Calling PeerManager's timer_tick_occurred".to_string();
1203-
if log_entries.get(&("lightning_background_processor".to_string(), desired_log)).is_some() &&
1204-
log_entries.get(&("lightning_background_processor".to_string(), second_desired_log)).is_some() {
1204+
let desired_log_1 = "Calling ChannelManager's timer_tick_occurred".to_string();
1205+
let desired_log_2 = "Calling ChainMonitor's rebroadcast_pending_claims".to_string();
1206+
let desired_log_3 = "Calling PeerManager's timer_tick_occurred".to_string();
1207+
if log_entries.get(&("lightning_background_processor".to_string(), desired_log_1)).is_some() &&
1208+
log_entries.get(&("lightning_background_processor".to_string(), desired_log_2)).is_some() &&
1209+
log_entries.get(&("lightning_background_processor".to_string(), desired_log_3)).is_some() {
12051210
break
12061211
}
12071212
}

0 commit comments

Comments
 (0)