mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-18 20:41:25 +00:00
refactor(identity): follow naming conventions for conversion methods
This PR renames some method names that don't follow Rust naming conventions or behave differently from what the name suggests: - Enforce "try" prefix on all methods that return `Result`. - Enforce "encode" method name for methods that return encoded bytes. - Enforce "to_bytes" method name for methods that return raw bytes. - Enforce "decode" method name for methods that convert encoded key. - Enforce "from_bytes" method name for methods that convert raw bytes. Pull-Request: #3775.
This commit is contained in:
@ -169,7 +169,7 @@ where
|
||||
.map(|addr| addr.to_vec())
|
||||
.collect();
|
||||
|
||||
let pubkey_bytes = info.public_key.to_protobuf_encoding();
|
||||
let pubkey_bytes = info.public_key.encode_protobuf();
|
||||
|
||||
let message = proto::Identify {
|
||||
agentVersion: Some(info.agent_version),
|
||||
@ -235,7 +235,7 @@ impl TryFrom<proto::Identify> for Info {
|
||||
addrs
|
||||
};
|
||||
|
||||
let public_key = PublicKey::from_protobuf_encoding(&msg.publicKey.unwrap_or_default())?;
|
||||
let public_key = PublicKey::try_decode_protobuf(&msg.publicKey.unwrap_or_default())?;
|
||||
|
||||
let observed_addr = match parse_multiaddr(msg.observedAddr.unwrap_or_default()) {
|
||||
Ok(a) => a,
|
||||
@ -386,7 +386,7 @@ mod tests {
|
||||
publicKey: Some(
|
||||
identity::Keypair::generate_ed25519()
|
||||
.public()
|
||||
.to_protobuf_encoding(),
|
||||
.encode_protobuf(),
|
||||
),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user