diff --git a/swarm/network/hive.go b/swarm/network/hive.go index a0b6b988ab..9bf87e79da 100644 --- a/swarm/network/hive.go +++ b/swarm/network/hive.go @@ -155,19 +155,31 @@ func (h *Hive) Run(p *BzzPeer) error { defer h.untrackPeer(p) dp := NewPeer(p, h.Kademlia) - depth, changed := h.On(dp) - // if we want discovery, advertise change of depth - if h.Discovery { - if changed { - // if depth changed, send to all peers - NotifyDepth(depth, h.Kademlia) - } else { - // otherwise just send depth to new peer - dp.NotifyDepth(depth) + + hasCap := func(capName string) (yes bool) { + for _, c := range p.Caps() { + if c.Name == capName { + return true + } } - NotifyPeer(p.BzzAddr, h.Kademlia) + return false + } + + if hasCap("stream") && hasCap("pss") { + depth, changed := h.On(dp) + // if we want discovery, advertise change of depth + if h.Discovery { + if changed { + // if depth changed, send to all peers + NotifyDepth(depth, h.Kademlia) + } else { + // otherwise just send depth to new peer + dp.NotifyDepth(depth) + } + NotifyPeer(p.BzzAddr, h.Kademlia) + } + defer h.Off(dp) } - defer h.Off(dp) return dp.Run(dp.HandleMsg) }