Skip to content

Commit e22f3f0

Browse files
committed
Ensure that fanout_peers is always non-empty if it's Some
1 parent 42c64a2 commit e22f3f0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

beacon_node/lighthouse_network/gossipsub/src/behaviour.rs

Lines changed: 8 additions & 2 deletions
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)