-
Notifications
You must be signed in to change notification settings - Fork 110
swarm/network: simplified neighbourhood depth calc #1013
Conversation
swarm/network/kademlia.go
Outdated
@@ -451,11 +451,14 @@ func (k *Kademlia) neighbourhoodDepth() (depth int) { | |||
var lastPo int | |||
|
|||
f := func(v pot.Val, i int) bool { | |||
if bytes.Equal(pot.ToBytes(v), pivotAddr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what condition should we be getting ourselves in these iterations. Isn't that actually an anomaly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe going back to po == 256
is simpler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justelad the question is about the iterator, not the value itself. Should the iterator ever return ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question. i guess not since the method name is EachNeighbour
and self
is not a neighbour. i'll make the change. good point 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nolash, come to think of it, that method name could be actually changed to EachPeer
, since it refers to actual peers connected, not just neighbours.
@zelig, I noted to @nolash that some of the terminology in the kademlia is somewhat misleading (as I already told you about minProxBinSize
), EachNeighbour
is the same case - we iterate over peers not neighbours, the iterator in this case should not have a notion of what is neighbouring and what is not, and that is up to the iteratee to assert. (my 2 cents)
6a2eaf1
to
12f1e68
Compare
@justelad Tests fail; I pushed a minor amend in comments, hope it's ok. |
8d2609c
to
fa8e0f1
Compare
…nabled waitTillHealty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved provided tests pass
this PR simplifies the neighbourhood depth calculation for the kademlia and reuses the same logic in the peer pot map creation