From 06450f28f5028f2baefa730424845fbd64e1354d Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Sat, 17 Jul 2021 15:21:01 +0200 Subject: [PATCH] Remove clone() calls on PublicKey for using to_peer_id --- protocols/gossipsub/tests/smoke.rs | 2 +- protocols/identify/src/identify.rs | 10 +++++----- protocols/kad/src/behaviour/test.rs | 2 +- protocols/relay/tests/lib.rs | 6 +++--- transports/plaintext/src/handshake.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/protocols/gossipsub/tests/smoke.rs b/protocols/gossipsub/tests/smoke.rs index 631eee9f2a66..841929a7f0ce 100644 --- a/protocols/gossipsub/tests/smoke.rs +++ b/protocols/gossipsub/tests/smoke.rs @@ -153,7 +153,7 @@ fn build_node() -> (Multiaddr, Swarm) { .multiplex(yamux::YamuxConfig::default()) .boxed(); - let peer_id = public_key.clone().to_peer_id(); + let peer_id = public_key.to_peer_id(); // NOTE: The graph of created nodes can be disconnected from the mesh point of view as nodes // can reach their d_lo value and not add other nodes to their mesh. To speed up this test, we diff --git a/protocols/identify/src/identify.rs b/protocols/identify/src/identify.rs index fa25d435f9d4..f9c9b137847e 100644 --- a/protocols/identify/src/identify.rs +++ b/protocols/identify/src/identify.rs @@ -478,7 +478,7 @@ mod tests { let protocol = Identify::new( IdentifyConfig::new("a".to_string(), pubkey.clone()) .with_agent_version("b".to_string())); - let swarm = Swarm::new(transport, protocol, pubkey.clone().to_peer_id()); + let swarm = Swarm::new(transport, protocol, pubkey.to_peer_id()); (swarm, pubkey) }; @@ -487,7 +487,7 @@ mod tests { let protocol = Identify::new( IdentifyConfig::new("c".to_string(), pubkey.clone()) .with_agent_version("d".to_string())); - let swarm = Swarm::new(transport, protocol, pubkey.clone().to_peer_id()); + let swarm = Swarm::new(transport, protocol, pubkey.to_peer_id()); (swarm, pubkey) }; @@ -555,7 +555,7 @@ mod tests { IdentifyConfig::new("a".to_string(), pubkey.clone()) // Delay identification requests so we can test the push protocol. .with_initial_delay(Duration::from_secs(u32::MAX as u64))); - let swarm = Swarm::new(transport, protocol, pubkey.clone().to_peer_id()); + let swarm = Swarm::new(transport, protocol, pubkey.to_peer_id()); (swarm, pubkey) }; @@ -566,7 +566,7 @@ mod tests { .with_agent_version("b".to_string()) // Delay identification requests so we can test the push protocol. .with_initial_delay(Duration::from_secs(u32::MAX as u64))); - let swarm = Swarm::new(transport, protocol, pubkey.clone().to_peer_id()); + let swarm = Swarm::new(transport, protocol, pubkey.to_peer_id()); (swarm, pubkey) }; @@ -612,7 +612,7 @@ mod tests { } } - swarm2.behaviour_mut().push(std::iter::once(pubkey1.clone().to_peer_id())); + swarm2.behaviour_mut().push(std::iter::once(pubkey1.to_peer_id())); } }) } diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index c6e51a015dde..9bd640878d04 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -64,7 +64,7 @@ fn build_node_with_config(cfg: KademliaConfig) -> (Multiaddr, TestSwarm) { .multiplex(yamux::YamuxConfig::default()) .boxed(); - let local_id = local_public_key.clone().to_peer_id(); + let local_id = local_public_key.to_peer_id(); let store = MemoryStore::new(local_id.clone()); let behaviour = Kademlia::with_config(local_id.clone(), store, cfg.clone()); diff --git a/protocols/relay/tests/lib.rs b/protocols/relay/tests/lib.rs index b16ad39e2486..601993f56198 100644 --- a/protocols/relay/tests/lib.rs +++ b/protocols/relay/tests/lib.rs @@ -1249,7 +1249,7 @@ fn build_swarm(reachability: Reachability, relay_mode: RelayMode) -> Swarm Swarm { let plaintext = PlainText2Config { local_public_key: local_public_key.clone(), }; - let local_peer_id = local_public_key.clone().to_peer_id(); + let local_peer_id = local_public_key.to_peer_id(); let transport = MemoryTransport::default(); @@ -1322,7 +1322,7 @@ fn build_keep_alive_only_swarm() -> Swarm { let plaintext = PlainText2Config { local_public_key: local_public_key.clone(), }; - let local_peer_id = local_public_key.clone().to_peer_id(); + let local_peer_id = local_public_key.to_peer_id(); let transport = MemoryTransport::default(); diff --git a/transports/plaintext/src/handshake.rs b/transports/plaintext/src/handshake.rs index a23b3b952c37..d981df4d9640 100644 --- a/transports/plaintext/src/handshake.rs +++ b/transports/plaintext/src/handshake.rs @@ -95,7 +95,7 @@ impl HandshakeContext { }; // Check the validity of the remote's `Exchange`. - if peer_id != public_key.clone().to_peer_id() { + if peer_id != public_key.to_peer_id() { debug!("the remote's `PeerId` isn't consistent with the remote's public key"); return Err(PlainTextError::InvalidPeerId) }