Skip to content

Commit fd7922c

Browse files
committed
remove mesh fix for subsequent commit
1 parent 0bf29a7 commit fd7922c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
## 0.50.0
2+
- Fix underflow when shuffling peers after prunning.
3+
See [PR 6183](https://github.com/libp2p/rust-libp2p/pull/6183)
4+
5+
See [PR 6112](https://github.com/libp2p/rust-libp2p/pull/6112)
6+
27
- Remove peer penalty for duplicate messages.
38
See [PR 6112](https://github.com/libp2p/rust-libp2p/pull/6112)
49

@@ -13,7 +18,7 @@
1318

1419
- Fix incorrect default values in ConfigBuilder
1520
See [PR 6113](https://github.com/libp2p/rust-libp2p/pull/6113)
16-
21+
1722
- Remove duplicated config `set_topic_max_transmit_size` method, prefer `max_transmit_size_for_topic`.
1823
See [PR 6173](https://github.com/libp2p/rust-libp2p/pull/6173).
1924

protocols/gossipsub/src/behaviour.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,8 @@ where
13661366
tracing::error!(peer_id = %peer_id, "Peer non-existent when handling graft");
13671367
return;
13681368
};
1369+
// Needs to be here to comply with the borrow checker.
1370+
let is_outbound = connected_peer.outbound;
13691371

13701372
// For each topic, if a peer has grafted us, then we necessarily must be in their mesh
13711373
// and they must be subscribed to the topic. Ensure we have recorded the mapping.
@@ -1453,9 +1455,10 @@ where
14531455
}
14541456

14551457
// check mesh upper bound and only allow graft if the upper bound is not reached
1458+
// or if it is an outbound peer
14561459
let mesh_n_high = self.config.mesh_n_high_for_topic(&topic_hash);
14571460

1458-
if peers.len() >= mesh_n_high {
1461+
if peers.len() >= mesh_n_high && !is_outbound {
14591462
to_prune_topics.insert(topic_hash.clone());
14601463
continue;
14611464
}
@@ -2225,9 +2228,7 @@ where
22252228
score_p1.partial_cmp(&score_p2).unwrap_or(Ordering::Equal)
22262229
});
22272230
// shuffle everything except the last retain_scores many peers (the best ones)
2228-
if peers.len() > self.config.retain_scores() {
2229-
shuffled[..peers.len() - self.config.retain_scores()].shuffle(&mut rng);
2230-
}
2231+
shuffled[..peers.len() - self.config.retain_scores()].shuffle(&mut rng);
22312232

22322233
// count total number of outbound peers
22332234
let mut outbound = shuffled

0 commit comments

Comments
 (0)