Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

proxbin evaluation in kademlia.Each* is incorrect #1042

@nolash

Description

@nolash
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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions