Skip to content

Commit

Permalink
Remove clone() calls on PublicKey for using to_peer_id
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jul 17, 2021
1 parent 7cbf674 commit 53eea7f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion protocols/gossipsub/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn build_node() -> (Multiaddr, Swarm<Gossipsub>) {
.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
Expand Down
10 changes: 5 additions & 5 deletions protocols/identify/src/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};

Expand All @@ -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)
};

Expand Down Expand Up @@ -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)
};

Expand All @@ -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)
};

Expand Down Expand Up @@ -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()));
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/behaviour/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! #
//! # let local_key = identity::Keypair::generate_ed25519();
//! # let local_public_key = local_key.public();
//! # let local_peer_id = local_public_key.clone().into_peer_id();
//! # let local_peer_id = local_public_key.into_peer_id();
//! # let plaintext = PlainText2Config {
//! # local_public_key: local_public_key.clone(),
//! # };
Expand Down
6 changes: 3 additions & 3 deletions protocols/relay/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ fn build_swarm(reachability: Reachability, relay_mode: RelayMode) -> Swarm<Combi
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();

Expand Down Expand Up @@ -1295,7 +1295,7 @@ fn build_keep_alive_swarm() -> Swarm<CombinedKeepAliveBehaviour> {
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();

Expand All @@ -1322,7 +1322,7 @@ fn build_keep_alive_only_swarm() -> Swarm<KeepAliveBehaviour> {
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();

Expand Down
2 changes: 1 addition & 1 deletion transports/plaintext/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl HandshakeContext<Local> {
};

// 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)
}
Expand Down

0 comments on commit 53eea7f

Please sign in to comment.