Skip to content

Commit 69cde69

Browse files
committed
address Marco review
1 parent 1685aae commit 69cde69

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

protocols/gossipsub/src/behaviour.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,11 @@ where
717717
}
718718

719719
// Get Peers from the mesh or fanout to publish a message to.
720-
// If partial set, filter out peers who only want partial messages for the topic.
720+
// If `exclude_partial_only` set, filter out peers who only want partial messages for the topic.
721721
fn get_publish_peers(
722722
&mut self,
723723
topic_hash: &TopicHash,
724-
filter_partial: bool,
724+
exclude_partial_only: bool,
725725
) -> HashSet<PeerId> {
726726
let mesh_n = self.config.mesh_n_for_topic(topic_hash);
727727

@@ -731,7 +731,7 @@ where
731731
.filter(|(_, peer)| {
732732
#[cfg(feature = "partial_messages")]
733733
{
734-
if filter_partial && peer.partial_only_topics.contains(topic_hash) {
734+
if exclude_partial_only && peer.partial_only_topics.contains(topic_hash) {
735735
return false;
736736
}
737737
}
@@ -768,7 +768,7 @@ where
768768
&self.connected_peers,
769769
topic_hash,
770770
needed_extra_peers,
771-
filter_partial,
771+
exclude_partial_only,
772772
|peer| {
773773
!mesh_peers.contains(peer)
774774
&& !self.explicit_peers.contains(peer)
@@ -802,7 +802,7 @@ where
802802
&self.connected_peers,
803803
topic_hash,
804804
mesh_n,
805-
filter_partial,
805+
exclude_partial_only,
806806
|p| {
807807
!self.explicit_peers.contains(p)
808808
&& !self
@@ -2777,7 +2777,7 @@ where
27772777
for topics in peer.partial_messages.values_mut() {
27782778
topics.retain(|_, partial| {
27792779
partial.ttl -= 1;
2780-
partial.ttl <= 0
2780+
partial.ttl == 0
27812781
});
27822782
}
27832783
}
@@ -3795,8 +3795,8 @@ fn peer_removed_from_mesh(
37953795
fn get_random_peers_dynamic(
37963796
connected_peers: &HashMap<PeerId, PeerDetails>,
37973797
topic_hash: &TopicHash,
3798-
// If we want to filter for partial only peers.
3799-
partial: bool,
3798+
// If we want to exclude partial only peers.
3799+
exclude_partial: bool,
38003800
// maps the number of total peers to the number of selected peers
38013801
n_map: impl Fn(usize) -> usize,
38023802
mut f: impl FnMut(&PeerId) -> bool,
@@ -3806,7 +3806,7 @@ fn get_random_peers_dynamic(
38063806
.filter_map(|(peer_id, peer)| {
38073807
#[cfg(feature = "partial_messages")]
38083808
{
3809-
if partial && peer.partial_only_topics.contains(topic_hash) {
3809+
if exclude_partial && peer.partial_only_topics.contains(topic_hash) {
38103810
return None;
38113811
}
38123812
}
@@ -3840,10 +3840,10 @@ fn get_random_peers(
38403840
connected_peers: &HashMap<PeerId, PeerDetails>,
38413841
topic_hash: &TopicHash,
38423842
n: usize,
3843-
partial: bool,
3843+
exclude_partial: bool,
38443844
f: impl FnMut(&PeerId) -> bool,
38453845
) -> BTreeSet<PeerId> {
3846-
get_random_peers_dynamic(connected_peers, topic_hash, partial, |_| n, f)
3846+
get_random_peers_dynamic(connected_peers, topic_hash, exclude_partial, |_| n, f)
38473847
}
38483848

38493849
/// Validates the combination of signing, privacy and message validation to ensure the

0 commit comments

Comments
 (0)