-
Notifications
You must be signed in to change notification settings - Fork 46
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
Making the /p2p
protocol type-safe
#73
Comments
Cross referencing a discussion about API stability and extracting more crates in |
(2) also makes sense when you consider that keys and |
My preference would be (2) |
I am in favor of making |
I will likely push (2) forward because it goes well with the planned modularization of |
Related: multiformats/rust-multiaddr#73. Depends-On: #3514. Pull-Request: #3656.
The
/p2p
protocol can only be followed by aPeerId
: https://github.com/libp2p/specs/blob/master/addressing/README.md#the-p2p-multiaddrAs per spec, a
PeerId
can only be a multihash with either SHA256 or the identity hash in case the encoded public key is less than 42 bytes.Currently,
/p2p
exposes aMultihash
which is more general than that.I see several options of how we can improve this situation:
PeerId
type fromrust-libp2p
into a dedicated crate and havemultiaddr
depend on thatidentity
module oflibp2p-core
into its own crate (keys +PeerId
)rust-libp2p
PeerId
type intomultiaddr
PeerId
type withinmultiaddr
that encodes the above invariantsAll of the above have their pros and cons.
Extracting
PeerId
into its own crate feels a bit odd because it would be a very small crate. On the other hand, it would encode a very important concept in a concise form so it may be worth it.The next step up would be a crate that encapsulates everything around keys in libp2p into its own crate, i.e.
libp2p-identity
. That is basically this module + thepeer_id
module.Personally, I'd be in favor of option (2). I think it makes sense to break out this part into a separate crate. We can heavily feature-flag that one to the point where the
multiaddr
crate itself only depends on the bits that define thePeerId
and doesn't come with any other dependencies.Input welcome!
cc @mxinden @dignifiedquire
The text was updated successfully, but these errors were encountered: