From: Matt Corallo Date: Thu, 9 Dec 2021 03:49:50 +0000 (+0000) Subject: Add a comment describing the timestamp field's use X-Git-Tag: v0.0.104~8^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2021-11-fix-update-announcements;p=rust-lightning Add a comment describing the timestamp field's use --- diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 2dba12b6..10c0ba57 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -847,6 +847,9 @@ impl NetworkGraph { None => Err(LightningError{err: "No existing channels for node_announcement".to_owned(), action: ErrorAction::IgnoreError}), Some(node) => { if let Some(node_info) = node.announcement_info.as_ref() { + // The timestamp field is somewhat of a misnomer - the BOLTs use it to order + // updates to ensure you always have the latest one, only vaguely suggesting + // that it be at least the current time. if node_info.last_update > msg.timestamp { return Err(LightningError{err: "Update older than last processed update".to_owned(), action: ErrorAction::IgnoreAndLog(Level::Gossip)}); } else if node_info.last_update == msg.timestamp { @@ -1084,6 +1087,12 @@ impl NetworkGraph { macro_rules! maybe_update_channel_info { ( $target: expr, $src_node: expr) => { if let Some(existing_chan_info) = $target.as_ref() { + // The timestamp field is somewhat of a misnomer - the BOLTs use it to + // order updates to ensure you always have the latest one, only + // suggesting that it be at least the current time. For + // channel_updates specifically, the BOLTs discuss the possibility of + // pruning based on the timestamp field being more than two weeks old, + // but only in the non-normative section. if existing_chan_info.last_update > msg.timestamp { return Err(LightningError{err: "Update older than last processed update".to_owned(), action: ErrorAction::IgnoreAndLog(Level::Gossip)}); } else if existing_chan_info.last_update == msg.timestamp {