-
Notifications
You must be signed in to change notification settings - Fork 999
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: Add Serialize and Deserialize to PeerId and MessageId #2405
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
One comment on the feature name in libp2p-core
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments :)
#[cfg(feature = "serde")] | ||
use serde::{Serialize, Deserialize}; | ||
|
||
/// Public keys with byte-lengths smaller than `MAX_INLINE_KEY_LENGTH` will be | ||
/// automatically used as the peer id using an identity multihash. | ||
const MAX_INLINE_KEY_LENGTH: usize = 42; | ||
|
||
/// Identifier of a peer of the network. | ||
/// | ||
/// The data is a multihash of the public key of the peer. | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[cfg(feature = "serde")] | |
use serde::{Serialize, Deserialize}; | |
/// Public keys with byte-lengths smaller than `MAX_INLINE_KEY_LENGTH` will be | |
/// automatically used as the peer id using an identity multihash. | |
const MAX_INLINE_KEY_LENGTH: usize = 42; | |
/// Identifier of a peer of the network. | |
/// | |
/// The data is a multihash of the public key of the peer. | |
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | |
/// Public keys with byte-lengths smaller than `MAX_INLINE_KEY_LENGTH` will be | |
/// automatically used as the peer id using an identity multihash. | |
const MAX_INLINE_KEY_LENGTH: usize = 42; | |
/// Identifier of a peer of the network. | |
/// | |
/// The data is a multihash of the public key of the peer. | |
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
This would contain it to a single line.
@laptou would you mind proposing this change in a separate pull request? |
I've created a new branch on my fork that has just the changes relevant to adding Serde, but I can't change the branch associated with this PR, so I will close it and open another one. |
serde
to thelibp2p
crateSerialize
andDeserialize
are implemented forPeerId
andgossipsub::MessageId
GossipsubConfigBuilder::build()
where it requires&self
to be borrowed for'static
lifetime due to lifetime elision