-
Notifications
You must be signed in to change notification settings - Fork 448
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
Introduce PeerId interface #955
Comments
@vasco-santos Can you explain the issue a bit further. Does interface for |
@nazarhussain I'm still working out all the details but here is my current thinking about this subject:
In my current working draft this already reduced significant number of dependencies, limiting it only to cases where:
We can eliminate 2nd case we are get type checks at compile time with TS. It does imply that some JS users may not get good errors if they pass garbage in, but I think that is reasonable for a low level library especially since users will get intellisence through vscode (and other LSP compatible editors). |
I have initially started by adding interface defs to libp2p-interface repo, but I'm starting to recognize several problems in comparison to approach taken by https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-types:
I think main problem here is that libp2p-interface serves double duty:
I'd like to propose following:
This would accomplish following:
|
Is anything actually uses Connection class ? I can't seem to find a single place where it's utilized |
@Gozala I am glad you raise these points. When we added I think we should distinct between the interfaces that target libp2p modules, like transport, encryption, peerDiscovery, ... and the primitives as you suggest. I have been working on making interfaces a monorepo libp2p/js-libp2p-interfaces#97 separating the compliance tests from the interfaces. I think we can probably reuse the same repo and add a package for the primitives. There is a bunch of work happening in parallel in this context, which is also not a priority, so we need to coordinate well on how we can advance in this direction. I would suggest just adding the PeerId interface in the interfaces, then get the monorepo and then create the primitives repo.
Yes, Connection class is used in the Upgrader https://github.com/libp2p/js-libp2p/blob/302bb9005891aa06b70a5f354bfac6b2d5a3c3b8/src/upgrader.js A raw connection from a transport will be transformed into a libp2p Connection in the upgrade process |
If that is only place maybe implementation should move to js-lipbp2 instead and we can just keep interface and tests in the libp2p-interfaces ? |
Triage notes:
|
@lidel I’m not sure I understand what is the problem though. Sure many libs will depend on libp2p-interfaces, but if there’s no runtime code pulled what’s the harm ? Most libs already already depend e.g on aegir but that doesn’t seem to be a problem. |
did you mean js-libp2p instead of ipld here ? |
Creates `PeerId` interface and its compliance tests. The discussion was initiated from libp2p/js-libp2p#955 and libp2p/js-peer-id#150 (review) Co-authored-by: achingbrain <alex@achingbrain.net>
Closing because libp2p/js-libp2p-interfaces#107 was merged. |
Idea here is to introduce PeerId as an interface so that all APIs can produce / consume as opposed to specific implementation in form of https://github.com/libp2p/js-peer-id
The text was updated successfully, but these errors were encountered: