From: Arik Sosman Date: Wed, 3 Jul 2024 21:02:05 +0000 (-0700) Subject: Send full node announcements following old pre-sync updates. X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1d7837306ec5b23aec792c9c13d70fba16c5253e;p=rapid-gossip-sync-server Send full node announcements following old pre-sync updates. This covers the following part of our serialization logic: If the pre-sync update was more than 6 days ago, serialize in full. --- diff --git a/src/serialization.rs b/src/serialization.rs index 2cbde46..decc580 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -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(); diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 9a5e22e..3fc37cc 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -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