We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I looked at the code of peerContactsSet, this function seems to be wrong.
func (p *peerContactsSet) next() []string { count := kNodes if count > len(p.set) { count = len(p.set) } x := make([]string, 0, count) xx := make(map[string]bool) //maps are easier to dedupe for range p.set { nid := p.ring.Move(1).Value.(string) <----this line will always return the first next item since p.ring never change its pos. if _, ok := xx[nid]; p.set[nid] && !ok { xx[nid] = true } if len(xx) >= count { break } } ...
The move function will return a new pointer rather than change the original pointer as demonstrated in this playground.
func (r *Ring) Move(n int) *Ring { if r.next == nil { return r.init() } switch { case n < 0: for ; n < 0; n++ { r = r.prev } case n > 0: for ; n > 0; n-- { r = r.next } } return r }
Need a PR to fix it?
The text was updated successfully, but these errors were encountered:
It's been a while since I've written this, but if you could write a unit test demonstrating the fix, a PR would be great, yes.
Sorry, something went wrong.
No branches or pull requests
When I looked at the code of peerContactsSet, this function seems to be wrong.
The move function will return a new pointer rather than change the original pointer as demonstrated in this playground.
Need a PR to fix it?
The text was updated successfully, but these errors were encountered: