Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gossipsub): make sure we have fanout peers when publish #5793

Merged
merged 3 commits into from
Jan 6, 2025
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
Expand Up @@ -35,6 +35,9 @@
- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).

- Fixe an issue where an `InsufficientPeers` error could occur under certain conditions, despite having peers subscribed to a topic.
See [PR 5793](https://github.com/libp2p/rust-libp2p/pull/5793).

## 0.47.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
9 changes: 7 additions & 2 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,14 @@ where
// Gossipsub peers
None => {
tracing::debug!(topic=%topic_hash, "Topic not in the mesh");
// `fanout_peers` is always non-empty if it's `Some`.
let fanout_peers = self
.fanout
.get(&topic_hash)
.filter(|peers| !peers.is_empty());
// If we have fanout peers add them to the map.
if self.fanout.contains_key(&topic_hash) {
for peer in self.fanout.get(&topic_hash).expect("Topic must exist") {
if let Some(peers) = fanout_peers {
for peer in peers {
recipient_peers.insert(*peer);
}
} else {
Expand Down
Loading