-
Notifications
You must be signed in to change notification settings - Fork 1.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
autorelay: break findRelays into multiple functions and avoid the goto #606
Conversation
(@Stebalien is picky and opinionated...)
88e02ea
to
776a53a
Compare
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 is a BUG; the new code will connect to ALL relays discovered instead of just DesiredRelays.
Also, I am not sure it is much of an improvement over the previous code; it has doubled in size and distributed the logic all over the place [tongue in cheek].
continue | ||
} | ||
ar.mx.Unlock() | ||
update = ar.tryRelay(ctx, pi) || update |
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.
BUG: this will potentially connect to ALL the relays.
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.
We need to count and break if we have more than desiredRelays.
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.
Or alternatively compare numRelays() >= DesiredRelays
.
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 am going to fix it with numRelays >= DesiredRelays
comparison since you seem to have an aversion to counters.
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.
Fixed the bug.
(@Stebalien is picky and opinionated...)