]> git.bitcoin.ninja Git - rapid-gossip-sync-server/commitdiff
Send full node announcements following old pre-sync updates.
authorArik Sosman <git@arik.io>
Wed, 3 Jul 2024 21:02:05 +0000 (14:02 -0700)
committerArik Sosman <git@arik.io>
Wed, 18 Sep 2024 17:07:24 +0000 (10:07 -0700)
This covers the following part of our serialization logic:

If the pre-sync update was more than 6 days ago, serialize in full.

src/serialization.rs
src/tests/mod.rs

index 2cbde46854a1d6b91a4b2fb6413409bf4d5f2284..decc580a8d170efd036aa87dc25d6b203d5e7447 100644 (file)
@@ -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();
index 9a5e22ee0444325109f8fa06caf2677964f1fd5c..3fc37ccdedc67ed898d8237ee9059289be827d75 100644 (file)
@@ -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