-
Notifications
You must be signed in to change notification settings - Fork 1k
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
core/src/peer_id: Support and output peer IDs as CIDs (RFC 0001) #2259
Comments
@mxinden, I have spent a few hours reading over the several documents related to this. Would it be okay for me to work on this issue with some guidance? |
Hi @JerryHue,
Yes for sure. Your help would be very much appreciated.
👍 I don't know how familiar you are with the stack. Feel free to post questions here or via mail. Note that there is a CID implementation in Rust. |
Hello again @mxinden! Despite my absence, I haven't forgotten about this issue! I believe I have implemented the changes as per the RFC stated, but I would like to make sure that I have not forgotten anything before I make my PR. I would like to ask certain questions that have passed through my mind while working on this. Previous public methodsEncoding to the string representationAs per the RFC requirements, the To encode the Decoding from the string representationThis one was tougher to separate, since we can only implement the
I believe this fits the criteria of the RFC the best, and causes the least friction when upgrading.
|
// TODO: this is in fact a CID; not sure if this should be handled in `from_bytes` or | |
// as a special case here | |
let node_id = PeerId::from_bytes(&peer.id).map_err(|_| invalid_data("invalid peer id"))?; |
The comment associated is confusing me a little. What does it mean by "handling as a special case"? Isn't the new representation of the
PeerId
a CID
? If so, why handle it as a special case?
Tests
Since this is a substantial PR, I would need to write some tests. Could you recommend me some behaviour to test whether it is working correctly? I am aware I need to implement the tests that confirm the behaviour stated in the RFC, but I am not sure if I should test other external places.
Sorry for the late reply here. I was sick for the last week.
👍 sounds good to me. In the future we would switch the
In my eyes a single function that can parse both is the way to go.
I would suggest a single function for
I think the comment suggests to either support
It would be great to have some While still minimal, we should as make sure we can parse the examples listed at the bottom of https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md. Thank you for the very thorough work thus far @JerryHue! |
Hello again, Max! Thank you for your follow up! I believe I have finished my changes, so I will follow up with my PR shortly. Thank you for the help and support! |
I find this RFC 1 (that I discover for the first time) very questionable. It's extremely over-engineered. But beyond that, I don't understand the motivation for storing a Why not build the bytes on the fly when |
rust-libp2p should implement RFC 0001.
Tracking issue: libp2p/specs#216
Also tackle:
rust-libp2p/protocols/kad/src/protocol.rs
Lines 102 to 104 in 9f331e5
The text was updated successfully, but these errors were encountered: