Skip to content

Commit 379a8e5

Browse files
Rename timer_chan_freshness_every_min for uniformity with PeerManager
1 parent 24c1cfe commit 379a8e5

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

background-processor/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::time::{Duration, Instant};
2727
/// * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
2828
/// writing it to disk/backups by invoking the callback given to it at startup.
2929
/// ChannelManager persistence should be done in the background.
30-
/// * Calling `ChannelManager::timer_chan_freshness_every_min()` every minute (can be done in the
30+
/// * Calling `ChannelManager::timer_tick_occurred()` every minute (can be done in the
3131
/// background).
3232
///
3333
/// Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
@@ -102,8 +102,8 @@ impl BackgroundProcessor {
102102
return Ok(());
103103
}
104104
if current_time.elapsed().as_secs() > CHAN_FRESHNESS_TIMER {
105-
log_trace!(logger, "Calling manager's timer_chan_freshness_every_min");
106-
channel_manager.timer_chan_freshness_every_min();
105+
log_trace!(logger, "Calling manager's timer_tick_occurred");
106+
channel_manager.timer_tick_occurred();
107107
current_time = Instant::now();
108108
}
109109
}
@@ -295,16 +295,16 @@ mod tests {
295295
}
296296

297297
#[test]
298-
fn test_chan_freshness_called() {
299-
// Test that ChannelManager's `timer_chan_freshness_every_min` is called every
298+
fn test_timer_tick_called() {
299+
// Test that ChannelManager's `timer_tick_occurred` is called every
300300
// `CHAN_FRESHNESS_TIMER`.
301301
let nodes = create_nodes(1, "test_chan_freshness_called".to_string());
302302
let data_dir = nodes[0].persister.get_data_dir();
303303
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);
304304
let bg_processor = BackgroundProcessor::start(callback, nodes[0].node.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone());
305305
loop {
306306
let log_entries = nodes[0].logger.lines.lock().unwrap();
307-
let desired_log = "Calling manager's timer_chan_freshness_every_min".to_string();
307+
let desired_log = "Calling manager's timer_tick_occurred".to_string();
308308
if log_entries.get(&("lightning_background_processor".to_string(), desired_log)).is_some() {
309309
break
310310
}

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub const INITIAL_COMMITMENT_NUMBER: u64 = (1 << 48) - 1;
250250
/// Liveness is called to fluctuate given peer disconnecton/monitor failures/closing.
251251
/// If channel is public, network should have a liveness view announced by us on a
252252
/// best-effort, which means we may filter out some status transitions to avoid spam.
253-
/// See further timer_chan_freshness_every_min.
253+
/// See further timer_tick_occurred.
254254
#[derive(PartialEq)]
255255
enum UpdateStatus {
256256
/// Status has been gossiped.

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub(super) struct ChannelHolder<Signer: Sign> {
337337
}
338338

339339
/// Events which we process internally but cannot be procsesed immediately at the generation site
340-
/// for some reason. They are handled in timer_chan_freshness_every_min, so may be processed with
340+
/// for some reason. They are handled in timer_tick_occurred, so may be processed with
341341
/// quite some time lag.
342342
enum BackgroundEvent {
343343
/// Handle a ChannelMonitorUpdate that closes a channel, broadcasting its current latest holder
@@ -402,7 +402,7 @@ pub type SimpleRefChannelManager<'a, 'b, 'c, 'd, 'e, M, T, F, L> = ChannelManage
402402
/// ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
403403
/// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
404404
/// offline for a full minute. In order to track this, you must call
405-
/// timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
405+
/// timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
406406
///
407407
/// Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
408408
/// a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
@@ -1913,10 +1913,10 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19131913
events.append(&mut new_events);
19141914
}
19151915

1916-
/// Free the background events, generally called from timer_chan_freshness_every_min.
1916+
/// Free the background events, generally called from timer_tick_occurred.
19171917
///
19181918
/// Exposed for testing to allow us to process events quickly without generating accidental
1919-
/// BroadcastChannelUpdate events in timer_chan_freshness_every_min.
1919+
/// BroadcastChannelUpdate events in timer_tick_occurred.
19201920
///
19211921
/// Expects the caller to have a total_consistency_lock read lock.
19221922
fn process_background_events(&self) {
@@ -1945,7 +1945,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19451945
/// This method handles all the details, and must be called roughly once per minute.
19461946
///
19471947
/// Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
1948-
pub fn timer_chan_freshness_every_min(&self) {
1948+
pub fn timer_tick_occurred(&self) {
19491949
let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
19501950
self.process_background_events();
19511951

@@ -3235,7 +3235,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
32353235
// We cannot broadcast our latest local state via monitor update (as
32363236
// Channel::force_shutdown tries to make us do) as we may still be in initialization,
32373237
// so we track the update internally and handle it when the user next calls
3238-
// timer_chan_freshness_every_min, guaranteeing we're running normally.
3238+
// timer_tick_occurred, guaranteeing we're running normally.
32393239
if let Some((funding_txo, update)) = failure.0.take() {
32403240
assert_eq!(update.updates.len(), 1);
32413241
if let ChannelMonitorUpdateStep::ChannelForceClosed { should_broadcast } = update.updates[0] {

lightning/src/ln/functional_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7569,7 +7569,7 @@ fn test_check_htlc_underpaying() {
75697569

75707570
#[test]
75717571
fn test_announce_disable_channels() {
7572-
// Create 2 channels between A and B. Disconnect B. Call timer_chan_freshness_every_min and check for generated
7572+
// Create 2 channels between A and B. Disconnect B. Call timer_tick_occurred and check for generated
75737573
// ChannelUpdate. Reconnect B, reestablish and check there is non-generated ChannelUpdate.
75747574

75757575
let chanmon_cfgs = create_chanmon_cfgs(2);
@@ -7585,8 +7585,8 @@ fn test_announce_disable_channels() {
75857585
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
75867586
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
75877587

7588-
nodes[0].node.timer_chan_freshness_every_min(); // dirty -> stagged
7589-
nodes[0].node.timer_chan_freshness_every_min(); // staged -> fresh
7588+
nodes[0].node.timer_tick_occurred(); // dirty -> stagged
7589+
nodes[0].node.timer_tick_occurred(); // staged -> fresh
75907590
let msg_events = nodes[0].node.get_and_clear_pending_msg_events();
75917591
assert_eq!(msg_events.len(), 3);
75927592
for e in msg_events {
@@ -7625,7 +7625,7 @@ fn test_announce_disable_channels() {
76257625
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[2]);
76267626
handle_chan_reestablish_msgs!(nodes[1], nodes[0]);
76277627

7628-
nodes[0].node.timer_chan_freshness_every_min();
7628+
nodes[0].node.timer_tick_occurred();
76297629
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
76307630
}
76317631

0 commit comments

Comments
 (0)