Skip to content

Commit fc0a57b

Browse files
committed
cargo fmt
1 parent bf1d6d7 commit fc0a57b

5 files changed

Lines changed: 28 additions & 21 deletions

File tree

protocols/gossipsub/src/behaviour.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ where
884884
let mut recipients = self.filter_publish_candidates(&topic_hash, candidates);
885885

886886
// We add the peers which also have the same group_id to the publish peers,
887-
// this allows us to reply to peers whom may not be on our mesh but still want the partial update.
887+
// this allows us to reply to peers whom may not be on our mesh
888+
// but still want the partial update.
888889
let group_id = partial_message.group_id();
889890
let transient_peers = self.connected_peers.keys().filter(|peer_id| {
890891
self.partial_messages_extension

protocols/gossipsub/src/behaviour/tests/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ use libp2p_core::ConnectedPoint;
5252
use rand::Rng;
5353

5454
use super::*;
55-
use crate::{types::RpcIn, types::SubscriptionOpts, IdentTopic as Topic};
55+
use crate::{
56+
types::{RpcIn, SubscriptionOpts},
57+
IdentTopic as Topic,
58+
};
5659

5760
/// Convenience alias for [`BehaviourTestBuilder`] with default transform and subscription filter.
5861
pub(super) type DefaultBehaviourTestBuilder =

protocols/gossipsub/src/behaviour/tests/partial.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ fn test_no_redundant_transfer() {
778778

779779
/// Verifies that:
780780
/// - After TTL expires, cached partials are cleaned up.
781-
/// - This is verified by observing that handle_received returns EmitEvent
782-
/// (as if seeing the group_id for the first time) instead of Publish.
781+
/// - This is verified by observing that handle_received
782+
/// returns EmitEvent (as if seeing the group_id for the first time) instead of Publish.
783783
#[test]
784784
fn test_heartbeat_ttl_expiry() {
785785
let topic_hash = TopicHash::from_raw("test-topic");
@@ -982,7 +982,8 @@ fn test_unsubscribe_cleanup() {
982982
}
983983

984984
/// Verifies that:
985-
/// - When a peer unsubscribes from a topic, their partial message state for that topic is cleaned up.
985+
/// - When a peer unsubscribes from a topic,
986+
/// their partial message state for that topic is cleaned up.
986987
/// - After the peer re-subscribes, we treat them as fresh (no knowledge of what they have).
987988
#[test]
988989
fn test_peer_unsubscribed_cleanup() {
@@ -1148,7 +1149,8 @@ fn test_peer_unsubscribed_preserves_other_topics() {
11481149
}
11491150

11501151
/// Verifies that:
1151-
/// - `requests_partial()` and `supports_partial()` return correct values based on peer subscription options.
1152+
/// - `requests_partial()` and `supports_partial()`
1153+
/// return correct values based on peer subscription options.
11521154
/// - Options are correctly tracked per peer per topic.
11531155
#[test]
11541156
fn test_subscription_options_tracking() {
@@ -1326,10 +1328,10 @@ fn test_metadata_only_update_unchanged_returns_empty() {
13261328
}
13271329

13281330
/// Verifies that:
1329-
/// - When Node A receives data from Node B, `RemotePartial::metadata` is updated
1330-
/// via `update_from_data` to reflect that B knows A now has those parts.
1331-
/// - On the next `handle_publish`, no message is sent because B's view of A's
1332-
/// metadata (`RemotePartial::metadata`) already matches A's current state.
1331+
/// - When Node A receives data from Node B, `RemotePartial::metadata` is updated via
1332+
/// `update_from_data` to reflect that B knows A now has those parts.
1333+
/// - On the next `handle_publish`, no message is sent because B's view of A's metadata
1334+
/// (`RemotePartial::metadata`) already matches A's current state.
13331335
#[test]
13341336
fn test_handle_publish_skips_redundant_update_after_receiving_data() {
13351337
let topic_hash = TopicHash::from_raw("test-topic");
@@ -1759,7 +1761,8 @@ fn test_partial_subscription_options_respected() {
17591761
/// Verifies that:
17601762
/// - A peer with `supports_partial: true` but `requests_partial: false` receives a PartialMessage.
17611763
/// - The PartialMessage contains metadata but NO body.
1762-
/// - A peer with both `supports_partial: true` and `requests_partial: true` receives body AND metadata.
1764+
/// - A peer with both `supports_partial: true` and `requests_partial: true` receives body AND
1765+
/// metadata.
17631766
#[test]
17641767
fn test_partial_requests_partial_metadata_only() {
17651768
let group_id: [u8; 8] = [1, 2, 3, 4, 5, 6, 7, 8];
@@ -1942,8 +1945,8 @@ fn test_partial_messages_response_on_receive() {
19421945
/// Verifies that:
19431946
/// - Peers with `requestsPartial=true` do NOT receive IHAVE messages during gossip.
19441947
/// - Peers with `requestsPartial=false` still receive IHAVE messages normally.
1945-
/// - This implements the spec: "When Gossiping, a node that supports partial messages
1946-
/// SHOULD NOT send an IHAVE to a peer that requested partial messages."
1948+
/// - This implements the spec: "When Gossiping, a node that supports partial messages SHOULD NOT
1949+
/// send an IHAVE to a peer that requested partial messages."
19471950
#[test]
19481951
fn test_ihave_not_sent_to_partial_peers() {
19491952
let config = ConfigBuilder::default()

protocols/gossipsub/src/extensions/partial_messages.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ pub trait Metadata: Debug + Send + Sync {
8383
/// Returns `true` if the `Metadata` was updated.
8484
fn update(&mut self, data: &[u8]) -> Result<bool, PartialError>;
8585
/// Attempts to update the local `Metadata` with the remote data received.
86-
/// This method is used to track the metadata that the remote peer believes the local system has.
87-
/// The default returns `false` as it is an optimization, indicating that the update logic
88-
/// has not been triggered in this implementation.
86+
/// This method is used to track the metadata that the remote peer believes the local system
87+
/// has. The default returns `false` as it is an optimization, indicating that the update
88+
/// logic has not been triggered in this implementation.
8989
fn update_from_data(&mut self, _data: &[u8]) -> Result<(), PartialError> {
9090
Ok(())
9191
}
@@ -260,8 +260,9 @@ impl State {
260260
Some(PeerMetadata::Local(peer_updated_metadata));
261261
Some(body)
262262
} else if remote_partial.peer_metadata.is_none() || action.need {
263-
// We have no data to eagerly send, but we want to transmit our metadata anyway, to
264-
// let the peer know of our metadata so that it sends us its data.
263+
// We have no data to eagerly send, but we want to transmit our metadata
264+
// anyway, to let the peer know of our metadata so
265+
// that it sends us its data.
265266
None
266267
} else {
267268
continue;

protocols/gossipsub/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,11 @@ mod topic;
114114
mod transform;
115115
mod types;
116116

117-
#[cfg(feature = "partial_messages")]
118-
pub use self::extensions::partial_messages;
119-
120117
#[cfg(feature = "metrics")]
121118
pub use metrics::Config as MetricsConfig;
122119

120+
#[cfg(feature = "partial_messages")]
121+
pub use self::extensions::partial_messages;
123122
pub use self::{
124123
behaviour::{Behaviour, Event, MessageAuthenticity},
125124
config::{Config, ConfigBuilder, ValidationMode, Version},

0 commit comments

Comments
 (0)