From 74aba460239179668a99bc92a9f51716f0674ccc Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 18 Feb 2020 11:37:10 +0100 Subject: [PATCH 1/2] Finish changes regarding PeerId, again --- core/src/peer_id.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/peer_id.rs b/core/src/peer_id.rs index 09a8d7cdaed..3ca321e1e53 100644 --- a/core/src/peer_id.rs +++ b/core/src/peer_id.rs @@ -26,7 +26,7 @@ use std::{convert::TryFrom, borrow::Borrow, fmt, hash, str::FromStr}; /// 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; +const MAX_INLINE_KEY_LENGTH: usize = 42; /// Identifier of a peer of the network. /// @@ -69,11 +69,11 @@ impl PeerId { // will switch to not hashing the key (i.e. the correct behaviour). // In other words, rust-libp2p 0.16 is compatible with all versions of rust-libp2p. // Rust-libp2p 0.12 and below is **NOT** compatible with rust-libp2p 0.17 and above. - let (hash_algorithm, canonical_algorithm) = /*if key_enc.len() <= MAX_INLINE_KEY_LENGTH { + let (hash_algorithm, canonical_algorithm) = if key_enc.len() <= MAX_INLINE_KEY_LENGTH { (multihash::Hash::Identity, Some(multihash::Hash::SHA2256)) - } else {*/ - (multihash::Hash::SHA2256, None); - //}; + } else { + (multihash::Hash::SHA2256, None) + }; let canonical = canonical_algorithm.map(|alg| multihash::encode(alg, &key_enc).expect("SHA2256 is always supported")); From ad04c9dd4aca46da108f13fdee683a5857198c94 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 24 Mar 2020 11:10:19 +0100 Subject: [PATCH 2/2] Fix bad merge --- core/src/peer_id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/peer_id.rs b/core/src/peer_id.rs index 0c9d889b04f..a4a900964c8 100644 --- a/core/src/peer_id.rs +++ b/core/src/peer_id.rs @@ -73,7 +73,7 @@ impl PeerId { let (hash_algorithm, canonical_algorithm) = if key_enc.len() <= MAX_INLINE_KEY_LENGTH { (Code::Identity, Some(Code::Sha2_256)) } else { - (Code::Sha2_256, None); + (Code::Sha2_256, None) }; let canonical = canonical_algorithm.map(|alg|