Skip to content

Commit

Permalink
fix(gossipsub): make sure we have fanout peers when publish
Browse files Browse the repository at this point in the history
This PR is to submit a fix in Lighthouse. sigp/lighthouse#6738

An `InsufficientPeers` error can occur under a particular condition, even if we have peers subscribed to a topic.

Pull-Request: #5793.
  • Loading branch information
ackintosh authored Jan 6, 2025
1 parent 7e3086d commit 34ac476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 34ac476

Please sign in to comment.