func (k *Kademlia) eachConn(base []byte, o int, f func(*Peer, int, bool) bool) {
if len(base) == 0 {
base = k.base
}
depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
k.conns.EachNeighbour(base, pof, func(val pot.Val, po int) bool {
if po > o {
return true
}
return f(val.(*Peer), po, po >= depth)
})
}
where in f func(*Peer, int, bool) the second parameter is po and the third isProxBin.
The depth is a property in relation to k.base - the base address of the kademlia.
However, the po compared to this depth to determine whether or not the Peer is in the proxbin (nearest neighbour) of the base of the kademlia is effectively the po between the passed base and the peer.
If the po of passed base in relation to Peer is higher than depth, the Peer can be erroneously be returned as a nearest neighbor.
Additionally, this raises the question of which assumptions have been made for the behavior of this function by the code that uses it.