Change representation of PeerId to CIDv1
Addresses #2259.
To encapsulate both errors from Multihash and CID, we change the interface of from_bytes to return a PeerIdError in the case of Err.
Friendly ping @JerryHue. Are you still interested in taking this fix to the finish line? :)
Hello again, @mxinden! I would like to try to bring this to the finish line throughout this week, sorry for the excruciatingly long wait. I wonder if I should improve this PR by taking into account @tomaka's comments on the original issue. What do you think?
@mxinden I believe this is waiting for your input.
This PR would break compatibility with Substrate/Polkadot and is a no-no for us.
This PR would break compatibility with Substrate/Polkadot and is a no-no for us.
Thanks for mentioning this. This definitely needs an upgrade path where we first support reading in a CIDv1 PeerId as described in the RFC.
For what it's worth, I've taken the decision for Polkadot a while ago to always use CIDv0. The spec precisely mentions how to encode it: https://spec.polkadot.network/#defn-peer-id. Being able to easily encode/decode PeerIds, and ensuring uniqueness of PeerIds, are more important than conforming to some libp2p spec outside of our control and that brings zero benefits for us.
It's not a deal breaker for adding support for CIDv1 in rust-libp2p, as long as there's always an option to force CIDv0.
@mxinden I believe this is waiting for your input.
As far as I can tell blocked on addressing comments above.
It's not a deal breaker for adding support for CIDv1 in rust-libp2p, as long as there's always an option to force CIDv0.
I suggest we support reading CIDv1 as a first iteration, though always writing and handling CIDv0s.
This pull request has merge conflicts. Could you please resolve them @JerryHue? 🙏
This pull request has merge conflicts. Could you please resolve them @JerryHue? 🙏
This pull request has merge conflicts. Could you please resolve them @JerryHue? 🙏