check for stream in caps on kademlia.On

This commit is contained in:
Anton Evangelatov 2019-01-18 17:06:47 +01:00
parent 537592a26e
commit 92c43bca9c

View file

@ -283,6 +283,22 @@ func (k *Kademlia) SuggestPeer() (suggestedPeer *BzzAddr, saturationDepth int, c
func (k *Kademlia) On(p *Peer) (uint8, bool) {
k.lock.Lock()
defer k.lock.Unlock()
caps := p.Caps()
var found bool
for _, c := range caps {
if c.Name == "stream" {
found = true
break
}
}
if !found {
depth := uint8(k.saturation())
return depth, false
}
var ins bool
k.conns, _, _, _ = pot.Swap(k.conns, p, Pof, func(v pot.Val) pot.Val {
// if not found live