to/into consistency for PublicKey and PeerId (#2145)

- 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)`.

- Add `From<&PublicKey> for PeerId`.

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
Ruben De Smet
2021-07-22 22:34:13 +02:00
committed by GitHub
parent 20183c1ea1
commit 371a7dab2c
63 changed files with 228 additions and 110 deletions

View File

@ -169,7 +169,7 @@ impl From<MessageAuthenticity> for PublishConfig {
match authenticity {
MessageAuthenticity::Signed(keypair) => {
let public_key = keypair.public();
let key_enc = public_key.clone().into_protobuf_encoding();
let key_enc = public_key.to_protobuf_encoding();
let key = if key_enc.len() <= 42 {
// The public key can be inlined in [`rpc_proto::Message::from`], so we don't include it
// specifically in the [`rpc_proto::Message::key`] field.
@ -181,7 +181,7 @@ impl From<MessageAuthenticity> for PublishConfig {
PublishConfig::Signing {
keypair,
author: public_key.into_peer_id(),
author: public_key.to_peer_id(),
inline_key: key,
}
}