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

Added support for when the last peer has been found #5

Closed
joshterrill opened this issue Jul 21, 2015 · 3 comments
Closed

Added support for when the last peer has been found #5

joshterrill opened this issue Jul 21, 2015 · 3 comments

Comments

@joshterrill
Copy link

I think it would be cool to have an event emitter for when the last peer in a swarm has been found. Thoughts?

@feross
Copy link
Member

feross commented Jul 27, 2015

There's no way to know when the actual "last peer" has been found. The best we can do is say that we've finished contacting all the trackers (or the requests have timed out) and finished the DHT lookup.

At some point in the future, an offline tracker might start working, new peers could come online, etc.

But a "lookupCompleted" event would be useful. Would you care to send a PR?

Related to: https://github.com/feross/instant.io/issues/34 and webtorrent/webtorrent#384

@feross
Copy link
Member

feross commented Jan 7, 2016

Ever since the dht rewrite a few days ago, you can use the dhtAnnounce event to tell you when no more peers will be found.

discovery.on('dhtAnnounce', function () {
  console.log('done finding peers for now, until next announce in ~15 minutes')
})

@feross feross closed this as completed Jan 7, 2016
@joshterrill
Copy link
Author

Sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants