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

Expose instance of libp2p to discovery instances #125

Closed
wanderer opened this issue Oct 16, 2017 · 2 comments
Closed

Expose instance of libp2p to discovery instances #125

wanderer opened this issue Oct 16, 2017 · 2 comments

Comments

@wanderer
Copy link

It would be nice if the libp2p instance was exposed to discovery instances. For example I would like libp2p-gossip-discovery to follow the discovery interface, but it need access to the instances peerBook and dail to populate correctly.

@daviddias
Copy link
Member

We currently don't have a global namespace where any module can pick up on the properties of a libp2p node (from peerInfo, swarm etc). We can't really do that because how JS dep management works and how require behaves, however, we could use DI for it.

That said, you won't need any of the above to achieve your goal (thanks for providing an example). You just need to:

  1. Create a libp2p node with a gossipDiscovery reference
  2. gossipDiscovery.attach(libp2pInstance) (or method that does the same).

This way, gossipDiscovery would have access to all the dial/handle methods of a libp2p instance and libp2p would be able to receive the peers discovered by gossipDiscovery.

Makes sense?

@wanderer
Copy link
Author

yep i think that makes sense

jacobheun pushed a commit to jacobheun/js-libp2p that referenced this issue Jul 29, 2019
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

No branches or pull requests

2 participants