Skip to content

Commit 46874bb

Browse files
committed
no need to save closure into variable
1 parent 254e535 commit 46874bb

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

protocols/gossipsub/src/behaviour.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,14 +1239,6 @@ where
12391239

12401240
let mut iwant_ids = HashSet::new();
12411241

1242-
let want_message = |id: &MessageId| {
1243-
if self.duplicate_cache.contains(id) {
1244-
return false;
1245-
}
1246-
1247-
!self.gossip_promises.contains(id)
1248-
};
1249-
12501242
for (topic, ids) in ihave_msgs {
12511243
// only process the message if we are subscribed
12521244
if !self.mesh.contains_key(&topic) {
@@ -1257,7 +1249,13 @@ where
12571249
continue;
12581250
}
12591251

1260-
for id in ids.into_iter().filter(want_message) {
1252+
for id in ids.into_iter().filter(|id| {
1253+
if self.duplicate_cache.contains(id) {
1254+
return false;
1255+
}
1256+
1257+
!self.gossip_promises.contains(id)
1258+
}) {
12611259
// have not seen this message and are not currently requesting it
12621260
if iwant_ids.insert(id) {
12631261
// Register the IWANT metric

0 commit comments

Comments
 (0)