mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-08-01 01:11:58 +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:
@@ -54,7 +54,7 @@ impl HandshakeContext<Local> {
|
||||
fn new(config: PlainText2Config) -> Self {
|
||||
let exchange = Exchange {
|
||||
id: Some(config.local_public_key.to_peer_id().to_bytes()),
|
||||
pubkey: Some(config.local_public_key.to_protobuf_encoding()),
|
||||
pubkey: Some(config.local_public_key.encode_protobuf()),
|
||||
};
|
||||
let mut buf = Vec::with_capacity(exchange.get_size());
|
||||
let mut writer = Writer::new(&mut buf);
|
||||
@@ -77,7 +77,7 @@ impl HandshakeContext<Local> {
|
||||
let mut reader = BytesReader::from_bytes(&exchange_bytes);
|
||||
let prop = Exchange::from_reader(&mut reader, &exchange_bytes)?;
|
||||
|
||||
let public_key = PublicKey::from_protobuf_encoding(&prop.pubkey.unwrap_or_default())?;
|
||||
let public_key = PublicKey::try_decode_protobuf(&prop.pubkey.unwrap_or_default())?;
|
||||
let peer_id = PeerId::from_bytes(&prop.id.unwrap_or_default())?;
|
||||
|
||||
// Check the validity of the remote's `Exchange`.
|
||||
|
Reference in New Issue
Block a user