Skip to content

Commit

Permalink
Send full node announcements following old pre-sync updates.
Browse files Browse the repository at this point in the history
This covers the following part of our serialization logic:

If the pre-sync update was more than 6 days ago, serialize in full.
  • Loading branch information
arik-so committed Sep 12, 2024
1 parent 6eb0a05 commit a585a85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,20 @@ pub(super) fn serialize_delta_set(channel_delta_set: DeltaSet, node_delta_set: N

serialization_set.full_update_defaults = default_update_values;

serialization_set.node_mutations = node_delta_set.into_iter().filter(|(_id, delta)| {
// either something changed, or this node is new
delta.strategy.is_some()
serialization_set.node_mutations = node_delta_set.into_iter().filter_map(|(id, mut delta)| {
if delta.strategy.is_none() {
return None;
}
if let Some(last_details_before_seen) = delta.last_details_before_seen.as_ref() {
if let Some(last_details_seen) = last_details_before_seen.seen {
if last_details_seen <= non_incremental_previous_update_threshold_timestamp {
delta.strategy = Some(NodeSerializationStrategy::Full)
}
}
Some((id, delta))
} else {
None
}
}).collect();

let mut node_feature_histogram: HashMap<&NodeFeatures, usize> = Default::default();
Expand Down
6 changes: 3 additions & 3 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ async fn test_node_announcement_delta_detection() {

assert_eq!(serialization.message_count, 3);
assert_eq!(serialization.node_announcement_count, 2);
assert_eq!(serialization.node_update_count, 2);
assert_eq!(serialization.node_feature_update_count, 2);
assert_eq!(serialization.node_address_update_count, 2);
assert_eq!(serialization.node_update_count, 1);
assert_eq!(serialization.node_feature_update_count, 1);
assert_eq!(serialization.node_address_update_count, 1);
}

/// If a channel has only seen updates in one direction, it should not be announced
Expand Down

0 comments on commit a585a85

Please sign in to comment.