Skip to content

Commit

Permalink
Merge pull request #82 from arik-so/gossip-v2-bugfixes
Browse files Browse the repository at this point in the history
Gossip v2 bugfixes
  • Loading branch information
TheBlueMatt authored Jun 7, 2024
2 parents bf20229 + adce514 commit c70cacc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,11 @@ fn serialize_delta<L: Deref + Clone>(serialization_details: &SerializationSet, s
};
}

if total_address_count > 0 {
// signal the presence of node addresses
current_node_delta_serialization[0] |= 1 << 2;
// serialize the actual addresses and count
total_address_count.write(&mut current_node_delta_serialization).unwrap();
current_node_delta_serialization.append(&mut address_serialization);
}
// signal the presence of node addresses
current_node_delta_serialization[0] |= 1 << 2;
// serialize the actual addresses and count
total_address_count.write(&mut current_node_delta_serialization).unwrap();
current_node_delta_serialization.append(&mut address_serialization);
}

if node_delta.has_feature_set_changed {
Expand Down
9 changes: 9 additions & 0 deletions src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,15 @@ pub(super) async fn fetch_node_updates<L: Deref>(client: &Client, last_sync_time
if address_set != last_seen_update.addresses {
current_node_delta.has_address_set_changed = true;
}
} else if !is_previously_processed_node_id {
if current_node_delta.last_details_before_seen.is_none() {
if !address_set.is_empty() {
current_node_delta.has_address_set_changed = true;
}
if unsigned_node_announcement.features != NodeFeatures::empty() {
current_node_delta.has_feature_set_changed = true;
}
}
}

if !is_previously_processed_node_id {
Expand Down
4 changes: 2 additions & 2 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ async fn test_node_announcement_delta_detection() {

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

Expand Down

0 comments on commit c70cacc

Please sign in to comment.