Skip to content
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

Merged
merged 2 commits into from
Apr 22, 2019

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Apr 20, 2019

(@Stebalien is picky and opinionated...)

  • No goto.
  • No counters (except the "retry" counter).
  • Dedup retry-wait logic.
  • Smaller functions.

@ghost ghost assigned Stebalien Apr 20, 2019
@ghost ghost added the status/in-progress In progress label Apr 20, 2019
@Stebalien Stebalien requested a review from vyzo April 20, 2019 21:25
Copy link
Contributor

@vyzo vyzo left a 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
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@ghost ghost assigned vyzo Apr 21, 2019
Copy link
Contributor

@vyzo vyzo left a 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 Stebalien merged commit 475283d into master Apr 22, 2019
@ghost ghost removed the status/in-progress In progress label Apr 22, 2019
@Stebalien Stebalien deleted the chore/cleanup-autorelay branch April 22, 2019 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants