Skip to content

Commit 7e0cdde

Browse files
authored
Make sure we have fanout peers when publish (#6738)
* Ensure that `fanout_peers` is always non-empty if it's `Some`
1 parent 42c64a2 commit 7e0cdde

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

beacon_node/lighthouse_network/gossipsub/src/behaviour.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,15 @@ where
679679
// Gossipsub peers
680680
None => {
681681
tracing::debug!(topic=%topic_hash, "Topic not in the mesh");
682+
// `fanout_peers` is always non-empty if it's `Some`.
683+
let fanout_peers = self
684+
.fanout
685+
.get(&topic_hash)
686+
.map(|peers| if peers.is_empty() { None } else { Some(peers) })
687+
.unwrap_or(None);
682688
// If we have fanout peers add them to the map.
683-
if self.fanout.contains_key(&topic_hash) {
684-
for peer in self.fanout.get(&topic_hash).expect("Topic must exist") {
689+
if let Some(peers) = fanout_peers {
690+
for peer in peers {
685691
recipient_peers.insert(*peer);
686692
}
687693
} else {

0 commit comments

Comments
 (0)