Skip to content

Commit 0fe2aef

Browse files
committed
Add a comment describing the timestamp field's use
1 parent d2ac683 commit 0fe2aef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lightning/src/routing/network_graph.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ impl NetworkGraph {
847847
None => Err(LightningError{err: "No existing channels for node_announcement".to_owned(), action: ErrorAction::IgnoreError}),
848848
Some(node) => {
849849
if let Some(node_info) = node.announcement_info.as_ref() {
850+
// The timestamp field is somewhat of a misnomer - the BOLTs use it to order
851+
// updates to ensure you always have the latest one, only vaguely suggesting
852+
// that it be at least the current time.
850853
if node_info.last_update > msg.timestamp {
851854
return Err(LightningError{err: "Update older than last processed update".to_owned(), action: ErrorAction::IgnoreAndLog(Level::Gossip)});
852855
} else if node_info.last_update == msg.timestamp {
@@ -1084,6 +1087,12 @@ impl NetworkGraph {
10841087
macro_rules! maybe_update_channel_info {
10851088
( $target: expr, $src_node: expr) => {
10861089
if let Some(existing_chan_info) = $target.as_ref() {
1090+
// The timestamp field is somewhat of a misnomer - the BOLTs use it to
1091+
// order updates to ensure you always have the latest one, only
1092+
// suggesting that it be at least the current time. For
1093+
// channel_updates specifically, the BOLTs discuss the possibility of
1094+
// pruning based on the timestamp field being more than two weeks old,
1095+
// but only in the non-normative section.
10871096
if existing_chan_info.last_update > msg.timestamp {
10881097
return Err(LightningError{err: "Update older than last processed update".to_owned(), action: ErrorAction::IgnoreAndLog(Level::Gossip)});
10891098
} else if existing_chan_info.last_update == msg.timestamp {

0 commit comments

Comments
 (0)