dht icon indicating copy to clipboard operation
dht copied to clipboard

Choose closest nodes without calculating distance?

Open ltzmaxwell opened this issue 6 years ago • 1 comments

It seems that function "lookupFiltered" is only choosing nodes that "wasContactedRecently", without calculating distance, right?

ltzmaxwell avatar Mar 12 '18 14:03 ltzmaxwell

Hi @ltzMaxwell. It's been a while since I wrote that code, but I assume that lookupFiltered uses traverse, which is by itself the distance calculation method.

Since the tree can be traversed multiple times for the same infohash, we skip the nodes that have been contacted already. So we specifically try to avoid a node that wasContactedRecently.

That's in this line: https://github.com/nictuku/dht/blob/b0d0998de3924b5d8a5f13c314870343b37e3d70/routing.go#L225

So I think the function is working. What do you think?

nictuku avatar Mar 12 '18 19:03 nictuku