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

refactor(iroh-net): Improve API to retrieve local endpoints #2041

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

flub
Copy link
Contributor

@flub flub commented Feb 22, 2024

Description

The API to retrieve local endpoints was split in two between the
current endpoints and updates to it. This was very hard to use right
without any race conditions.

This replaces it with a single API which returns a stream. This is a
little bit wordier to use if you just need the current local item, but
much harder to misuse.

Notes & open questions

It would be possible to add a convenient .current_local_endpoints()
API if we wanted. Not sure this is really worth it.

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

The API to retrieve local endpoints was split in two between the
current endpoints and updates to it.  This was very hard to use right
without any race conditions.

This replaces it with a single API which returns a stream.  This is a
little bit wordier to use if you just need the current local item, but
much harder to misuse.
@flub flub requested a review from dignifiedquire February 22, 2024 13:56
Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for improving this horrible api!

@flub flub added this pull request to the merge queue Feb 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 22, 2024
@flub flub enabled auto-merge February 22, 2024 15:56
@flub flub added this pull request to the merge queue Feb 22, 2024
Merged via the queue into main with commit 540fd88 Feb 22, 2024
19 checks passed
@flub flub deleted the flub/api-local-endpoints branch February 22, 2024 16:22
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2024
## Description

This incorporates two fixes:

- The .set_preferred_port() function was completely ignoring the passed
port. This is now plugged through to the rebind. Nobody was using this
function before though. I'm not so sure how useful it is.

- When rebinding the locally bound sockets change. This means we have to
do a new netcheck as otherwise we won't know about our new endpoints
until a new netcheck runs on it's regular schedule.

## Notes & open questions

This is kind of split off from #2041 because it ends up doing unrelated
fixes just for an improvement to tests.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
fubuloubu pushed a commit to ApeWorX/iroh that referenced this pull request Feb 27, 2024
…ter#2041)

## Description

The API to retrieve local endpoints was split in two between the
current endpoints and updates to it.  This was very hard to use right
without any race conditions.

This replaces it with a single API which returns a stream.  This is a
little bit wordier to use if you just need the current local item, but
much harder to misuse.

## Notes & open questions

It would be possible to add a convenient `.current_local_endpoints()`
API if we wanted.  Not sure this is really worth it.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
fubuloubu pushed a commit to ApeWorX/iroh that referenced this pull request Feb 27, 2024
## Description

This incorporates two fixes:

- The .set_preferred_port() function was completely ignoring the passed
port. This is now plugged through to the rebind. Nobody was using this
function before though. I'm not so sure how useful it is.

- When rebinding the locally bound sockets change. This means we have to
do a new netcheck as otherwise we won't know about our new endpoints
until a new netcheck runs on it's regular schedule.

## Notes & open questions

This is kind of split off from n0-computer#2041 because it ends up doing unrelated
fixes just for an improvement to tests.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants