harnen / p2p-service-discovery

0 stars 4 forks source link

Grab nodes from adjacent buckets during FINDNODE if the specified buckets doesn't have enough nodes. #11

Closed harnen closed 4 years ago

harnen commented 4 years ago

Based on the documentation, nodes returns then nodes from requested bucket k, k+1 and k-1, the resulting list is cut to fit the response size limit.

If k=0 or k=MAX the current implementation will not overflow. (if k=0, only buckets 0 and 1 will be returned). This can be changed if needed.

srene commented 4 years ago

According to https://github.com/ethereum/devp2p/blob/master/discv5/discv5-theory.md#lookup-protocol shouldn't this be implemented in the node that sends the query instead of directly in the response? And, shouldn't be distance, distance+1 and distance-1, instead of distance, distance+1 and distance+2? Distance+2 is not the adjacent bucket.

harnen commented 4 years ago

But here it seems that they put all the distances directly in the message. We can probably check with Felix.

And I never use k+2. Where have you found it?

srene commented 4 years ago

But here i think is where it sends the findnode request, not the response. The distance+2 code i've seen it here. Maybe I'm looking at the wrong code... ;)

harnen commented 4 years ago

Good catch! I don't why I've put +2 :o Anyway, it's fixed.

For sending 3 buckets right away, I think it's similar to pinging. It just generates additional messages without bringing much to the table. Let's keep it as it is and we can consult with Felix during our next checkpoint.