Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

libp2p new config #1451

Closed
pgte opened this issue Jul 18, 2018 · 4 comments
Closed

libp2p new config #1451

pgte opened this issue Jul 18, 2018 · 4 comments
Labels
kind/support A question or request for support

Comments

@pgte
Copy link
Contributor

pgte commented Jul 18, 2018

I need a version of the libp2p new config to land here so that I can fix peer-base/peer-base#1.
Any plans for this?

@alanshaw
Copy link
Member

That was released in v0.22 of libp2p which js-ipfs currently depends on.

@alanshaw alanshaw added kind/support A question or request for support status/in-progress In progress labels Jul 18, 2018
@pgte
Copy link
Contributor Author

pgte commented Jul 18, 2018

When passing classes instead of instances to the modules.transport and modules.discovery, I'm getting this error from what I believe is js-ipfs validation:

[1] "modules" must be an object
      at Object.exports.process (node_modules/joi/lib/errors.js:196:19)
      at internals.Object._validateWithOptions (node_modules/joi/lib/types/any/index.js:675:31)
      at module.exports.internals.Any.root.validate (node_modules/joi/lib/index.js:138:23)
      at module.exports.internals.Any.root.attempt (node_modules/joi/lib/index.js:167:29)
      at Object.module.exports.validate (node_modules/ipfs/src/core/config.js:52:43)
      at new IPFS (node_modules/ipfs/src/core/index.js:36:22)
      at module.exports (src/transport/ipfs.js:9:16)
      at new App (src/app.js:16:17)
      at module.exports (src/app.js:9:10)
      at Context.it (test/app.spec.js:30:11)

@alanshaw
Copy link
Member

Yes, it currently has to be an object like { transport: [], peerDiscovery: [] }. This is the case in the libp2p module too.

Looking at the code, an object with a peerInfo property will be passed to peerDiscovery items if they are a function that can be new'd up.

https://github.com/libp2p/js-libp2p/blob/d9059dbad9b33e2c1434b5c13ff500ed34aa348f/src/index.js#L175

Transports don't get the peerInfo:

https://github.com/libp2p/js-libp2p/blob/master/src/index.js#L133

If that's not going to work for your use case then we'll need to open an issue in libp2p and come up with a better solution.

@pgte pgte added kind/bug A bug in existing code (including security flaws) kind/support A question or request for support and removed kind/support A question or request for support kind/bug A bug in existing code (including security flaws) labels Jul 18, 2018
@pgte
Copy link
Contributor Author

pgte commented Jul 18, 2018

@alanshaw Ah right, I misunderstood the error. I remember now: indeed I was trying to get a peerInfo instance into the modules constructor, but it looks like I'm still not getting one.

I'm bringing this to libp2p here.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants