-
Notifications
You must be signed in to change notification settings - Fork 445
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
feat: discovery modules from transports should be added #510
feat: discovery modules from transports should be added #510
Conversation
78040ca
to
7f216a9
Compare
src/index.js
Outdated
@@ -448,7 +448,8 @@ class Libp2p extends EventEmitter { | |||
config = { ...config, ...this._config.peerDiscovery[DiscoveryService.tag] } | |||
} | |||
|
|||
if (config.enabled) { | |||
if (config.enabled && | |||
!this._discovery.filter((service) => service.tag === DiscoveryService.tag).length) { // not already added |
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.
Should we just make this._discovery
a Map? They require a tag, it might be easier for checking existence and getting specific ones should we need to do that.
test/peer-discovery/index.spec.js
Outdated
|
||
await libp2p.start() | ||
|
||
expect(libp2p._discovery).to.have.lengthOf(1) |
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 should verify this is the discovery service we expect. Making libp2p. _discovery
a map would make this easy to do.
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
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.
One minor thing, otherwise this is gtg! 🎉
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
* feat: discovery modules from transports should be added * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: address review * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
* feat: discovery modules from transports should be added * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: address review * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
Discovery modules within Transports automatically added to discovery if enabled