-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
Kademlia EachBin bug fix and unit tests #18338
Conversation
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.
pending on merge of new depth calculation otherwise chunks in bins with no peers (empty bins shallower than depth) will NOT be synced
if startPo > 0 && endPo != k.MaxProxDisplay { | ||
startPo = endPo + 1 | ||
} | ||
//if the peer's bin is smaller than the kademlia depth, |
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.
but now this PR really needs to wait for the new depth calculation
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.
agreed
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.
Please do not use "smaller". Please review the terminology introduced here:
If you don't agree with the terms, let's discuss and settle on something everyone can agree with.
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.
Shouldn't this be PR'd to ethersphere instead?
//EachBin iterates over each connection of a kademlia table, per bin. | ||
//So `po` will be representing the bin value (0..255), while `val` represents an | ||
//existing connection inside that bin. | ||
//For any such connection found, the parameter func `eachBinFunc` will be executed |
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.
I've also made a comment for this. Which one do we keep?
if startPo > 0 && endPo != k.MaxProxDisplay { | ||
startPo = endPo + 1 | ||
} | ||
//if the peer's bin is smaller than the kademlia depth, |
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.
Please do not use "smaller". Please review the terminology introduced here:
If you don't agree with the terms, let's discuss and settle on something everyone can agree with.
015 0 | 0 | ||
========================================================================= | ||
*/ | ||
func TestEachBin(t *testing.T) { |
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.
A unit test should not be opinionated about the context which it's used by consumers. I find the terms "subscription" etc wholly out of place here. Keep it minimal to the exact expectations of what this function should provide and nothing 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.
But since that is the point of the test not the iterator (despite the name of the PR), the test should be in the stream package rather than here.
has been obsoleted by #18355 |
This PR adds a unit test for the
kademlia.EachBin
function.This function is responsible for the correct registration of syncing subscriptions for the
stream
protocol.Apart from fixing a couple of bugs, most importantly this PR introduces a unit test.
ethersphere/swarm#1071 is an issue to refactor the
EachBin
function; with a working unit test that refactor gets a test-driven approach.Replaces #18284 (which was for discussion)