-
Notifications
You must be signed in to change notification settings - Fork 950
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
to/into consistency for PublicKey and PeerId #2145
Conversation
…otobuf_encoding(&self)`
10f168d
to
99d0834
Compare
Feel free to only pick the first commit. Some comment on the Anyway, this include the changelog entry in two separate steps, such that you can cherry-pick the first commit. Preferrably, #2142 is merged before this one, because that yields one less conflict (in core/CHANGELOG...). |
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.
A few nits!
core/src/peer_id.rs
Outdated
@@ -114,13 +113,19 @@ impl PeerId { | |||
pub fn is_public_key(&self, public_key: &PublicKey) -> Option<bool> { | |||
let alg = Code::try_from(self.multihash.code()) | |||
.expect("Internal multihash is always a valid `Code`"); | |||
let enc = public_key.clone().into_protobuf_encoding(); | |||
let enc = public_key.clone().to_protobuf_encoding(); |
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.
This and other clone
s are redundant now I believe.
core/src/peer_id.rs
Outdated
for _ in 0 .. 5000 { | ||
for _ in 0..5000 { |
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.
Unfortunately, we don't (yet) have rustfmt in here.
For this diff size, I think it is okay to leave it in but with larger diffs, it is best to not autoformat in rust-libp2p :)
See #1966.
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.
Damnit, I thought I had turned it off for every file. Will fix.
core/CHANGELOG.md
Outdated
@@ -1,3 +1,11 @@ | |||
- Change `PublicKey::into_protobuf_encoding` to `PublicKey::to_protobuf_encoding`. | |||
Change `PublicKey::into_peer_id` to `PublicKey::to_peer_id`. | |||
Change `PeerId::from_public_key(PublicKey)` to `PeerId::from_public_key(PublicKey)`. |
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.
These signatures are identical 😁
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.
I probably didn't catch all of the clone()s, mostly because clippy also creates some noise in several other places.
That should be fixed if you merge latest master into your PR. That will include #2139.
If wanted, I can squash that last commit into the PeerId commit. 7cbf674 should address your nits, and I'll gladly squash that into 99d0834 :-)
Appreciate the effort! Rust-libp2p uses squash-merge though so the individual patches of the PR will be gone anyway :)
Still nice to not force-push because then at least GitHub gives you a nice "changes since your last review" button.
LGTM!
47f3666
to
06450f2
Compare
I rebased on master, then squashed as I said, I'll add more fixups for the clones now. |
Still quite a bit of clippy noise going on, I fixed the When I fixed some stuff that |
cb2a3e6
to
1a7c043
Compare
f183af9
to
cd0523d
Compare
I think this is ready for merge, if everyone is okay with the slightly breaking change. |
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.
Thank you for the patch @rubdos. Appreciate the work you put into this and also very much in favor of being consistent with Rust's naming conventions.
Given that this is the first patch after the recent release, and also given that this is a breaking change in libp2p-core
, would you mind cherry-picking the commit below into this branch?
My pleasure!
Of course, done! |
Seems like there was later an incompatible commit. Here's a patch, @mxinden .
|
As per discussion in #2142:
PublicKey::into_protobuf_encoding(self)
toPublicKey::to_protobuf_encoding(&self)
PublicKey::into_peer_id(self)
toPublicKey::to_peer_id(&self)
clone()
's.The latter goes via a
From
implementation.