Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 0.50.0
- Fix underflow when shuffling peers after prunning.
See [PR 6183](https://github.com/libp2p/rust-libp2p/pull/6183)

- Remove peer penalty for duplicate messages.
See [PR 6112](https://github.com/libp2p/rust-libp2p/pull/6112)

Expand Down
4 changes: 3 additions & 1 deletion protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,9 @@ where
score_p1.partial_cmp(&score_p2).unwrap_or(Ordering::Equal)
});
// shuffle everything except the last retain_scores many peers (the best ones)
shuffled[..peers.len() - self.config.retain_scores()].shuffle(&mut rng);
if peers.len() > self.config.retain_scores() {
shuffled[..peers.len() - self.config.retain_scores()].shuffle(&mut rng);
}

// count total number of outbound peers
let mut outbound = shuffled
Expand Down