Skip to content

Commit b324712

Browse files
committed
f minor tweaks
1 parent b60ec94 commit b324712

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lightning/src/routing/network_graph.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ use bitcoin::hashes::hex::ToHex;
4646
#[cfg(feature = "std")]
4747
use std::time::{SystemTime, UNIX_EPOCH};
4848

49+
/// We remove stale channel directional info two weeks after the last update, per BOLT 7's
50+
/// suggestion.
4951
const STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS: u64 = 60 * 60 * 24 * 14;
5052

5153
/// The maximum number of extra bytes which we do not understand in a gossip message before we will
@@ -1065,7 +1067,7 @@ impl NetworkGraph {
10651067
///
10661068
/// While there is no formal requirement that nodes regularly re-broadcast their channel
10671069
/// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
1068-
/// pruning occurs for updates which are at least two weeks old, which we implement here.
1070+
/// pruning occur for updates which are at least two weeks old, which we implement here.
10691071
///
10701072
///
10711073
/// This method is only available with the `std` feature. See
@@ -1081,13 +1083,14 @@ impl NetworkGraph {
10811083
///
10821084
/// While there is no formal requirement that nodes regularly re-broadcast their channel
10831085
/// updates every two weeks, the non-normative section of BOLT 7 currently suggests that
1084-
/// pruning occurs for updates which are at least two weeks old, which we implement here.
1086+
/// pruning occur for updates which are at least two weeks old, which we implement here.
10851087
///
10861088
/// This function takes the current unix time as an argument. For users with the `std` feature
10871089
/// enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
10881090
pub fn remove_stale_channels_with_time(&self, current_time_unix: u64) {
10891091
let mut channels = self.channels.write().unwrap();
10901092
// Time out if we haven't received an update in at least 14 days.
1093+
if current_time_unix > u32::max_value() { return; } // Remove by 2106
10911094
let min_time_unix: u32 = (current_time_unix - STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS) as u32;
10921095
// Sadly BTreeMap::retain was only stabilized in 1.53 so we can't switch to it for some
10931096
// time.

0 commit comments

Comments
 (0)