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: Add a context.Context to WithPeerSource callback #1736

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

Jorropo
Copy link
Contributor

@Jorropo Jorropo commented Sep 2, 2022

The main point of this is to stop the search when the libp2p stops.
I've added that this might be used in the future to notify when AutoRelay is satisfied just to not close any door in the future but havn't implemented anything like that.

@@ -59,7 +59,7 @@ type relayFinder struct {
ctxCancel context.CancelFunc
ctxCancelMx sync.Mutex

peerSource func(int) <-chan peer.AddrInfo
peerSource func(context.Context, int) <-chan peer.AddrInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to remove the int here, and have the caller give us new nodes until we cancel the context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe ?
The int allows to create a buffered channel of the right size for synchronous or partially synchronous implementations tho.

@BigLep BigLep added this to the Best Effort Track milestone Sep 9, 2022
@marten-seemann marten-seemann merged commit 70c1f81 into libp2p:master Sep 16, 2022
@Jorropo Jorropo deleted the context-peer-source branch September 16, 2022 13:26
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.

3 participants