-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use accurate bucket logic #64
Conversation
@Stebalien What's the motivation on this i.e. what do we gain by not adding peers to the left ? |
We're adding peers from all buckets. The change is that, instead of adding peers from buckets from the right until we have enough peers, we just add all peers from buckets to the right, then sort them based on their distance to the target, then trim back down to K peers. This is strictly more accurate as all peers to the right are the same order of magnitude (same CPL). |
@Stebalien LGTM. Please can you merge this ? |
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.
LGTM
|
||
for i := cpl + 1; i < len(rt.buckets) && pds.Len() < count; i++ { | ||
pds.appendPeersFromList(rt.buckets[i].list) | ||
if pds.Len() < count { |
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.
Yep. This is more accurate. And sorting happens later, I assume.
I'm blocking this on #66. Once we land that, we should store the pre-hashed peer ID in the routing table. Otherwise, if we're missing a single peer in the closest bucket, we'll have to hash all the peers to the right when sorting them. |
PR to store pre-hashed peerId and re-use them in |
This reverts an optimization where we fudged the closer peers when returning responses to users when we were within a power of two to the target.
08f2efa
to
0a02da2
Compare
This reverts an optimization where we fudged the closer peers when returning responses to users when we were within a power of two to the target.