mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/network: revert: check stream and pss caps in Hive.Run
This reverts commit 3029a8289c.
This commit is contained in:
parent
ca93204d40
commit
94b3b0586a
1 changed files with 11 additions and 23 deletions
|
|
@ -155,31 +155,19 @@ func (h *Hive) Run(p *BzzPeer) error {
|
||||||
defer h.untrackPeer(p)
|
defer h.untrackPeer(p)
|
||||||
|
|
||||||
dp := NewPeer(p, h.Kademlia)
|
dp := NewPeer(p, h.Kademlia)
|
||||||
|
depth, changed := h.On(dp)
|
||||||
hasCap := func(capName string) (yes bool) {
|
// if we want discovery, advertise change of depth
|
||||||
for _, c := range p.Caps() {
|
if h.Discovery {
|
||||||
if c.Name == capName {
|
if changed {
|
||||||
return true
|
// if depth changed, send to all peers
|
||||||
}
|
NotifyDepth(depth, h.Kademlia)
|
||||||
|
} else {
|
||||||
|
// otherwise just send depth to new peer
|
||||||
|
dp.NotifyDepth(depth)
|
||||||
}
|
}
|
||||||
return false
|
NotifyPeer(p.BzzAddr, h.Kademlia)
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
return dp.Run(dp.HandleMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue