Skip to content

Commit 34ac476

Browse files
authored
fix(gossipsub): make sure we have fanout peers when publish
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.
1 parent 7e3086d commit 34ac476

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
3636
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).
3737

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

4043
<!-- Update to libp2p-swarm v0.45.0 -->

protocols/gossipsub/src/behaviour.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,14 @@ where
675675
// Gossipsub peers
676676
None => {
677677
tracing::debug!(topic=%topic_hash, "Topic not in the mesh");
678+
// `fanout_peers` is always non-empty if it's `Some`.
679+
let fanout_peers = self
680+
.fanout
681+
.get(&topic_hash)
682+
.filter(|peers| !peers.is_empty());
678683
// If we have fanout peers add them to the map.
679-
if self.fanout.contains_key(&topic_hash) {
680-
for peer in self.fanout.get(&topic_hash).expect("Topic must exist") {
684+
if let Some(peers) = fanout_peers {
685+
for peer in peers {
681686
recipient_peers.insert(*peer);
682687
}
683688
} else {

0 commit comments

Comments
 (0)