Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/authority-discovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn get_addresses_and_authority_id() {
let remote_addr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333"
.parse::<Multiaddr>()
.unwrap()
.with(Protocol::P2p(remote_peer_id.clone().into()));
.with(Protocol::P2p(remote_peer_id.into()));

let test_api = Arc::new(TestApi { authorities: vec![] });

Expand Down
2 changes: 1 addition & 1 deletion client/authority-discovery/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ where
if a.iter().any(|p| matches!(p, multiaddr::Protocol::P2p(_))) {
a
} else {
a.with(multiaddr::Protocol::P2p(peer_id.clone()))
a.with(multiaddr::Protocol::P2p(peer_id))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion client/authority-discovery/src/worker/addr_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ mod tests {
let multiaddr1 = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333"
.parse::<Multiaddr>()
.unwrap()
.with(Protocol::P2p(peer_id.clone().into()));
.with(Protocol::P2p(peer_id.into()));
let multiaddr2 = "/ip6/2002:db8:0:0:0:0:0:2/tcp/30133"
.parse::<Multiaddr>()
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion client/authority-discovery/src/worker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl NetworkProvider for TestNetwork {

impl NetworkStateInfo for TestNetwork {
fn local_peer_id(&self) -> PeerId {
self.peer_id.clone()
self.peer_id
}

fn external_addresses(&self) -> Vec<Multiaddr> {
Expand Down
10 changes: 5 additions & 5 deletions client/finality-grandpa/src/communication/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl<N: Ord> Peers<N> {
let mut peers = self
.inner
.iter()
.map(|(peer_id, info)| (peer_id.clone(), info.clone()))
.map(|(peer_id, info)| (*peer_id, info.clone()))
.collect::<Vec<_>>();

peers.shuffle(&mut rand::thread_rng());
Expand All @@ -618,9 +618,9 @@ impl<N: Ord> Peers<N> {
let mut n_authorities_added = 0;
for peer_id in shuffled_authorities {
if n_authorities_added < half_lucky {
first_stage_peers.insert(peer_id.clone());
first_stage_peers.insert(*peer_id);
} else if n_authorities_added < one_and_a_half_lucky {
second_stage_peers.insert(peer_id.clone());
second_stage_peers.insert(*peer_id);
} else {
break
}
Expand All @@ -637,11 +637,11 @@ impl<N: Ord> Peers<N> {
}

if first_stage_peers.len() < LUCKY_PEERS {
first_stage_peers.insert(peer_id.clone());
first_stage_peers.insert(*peer_id);
second_stage_peers.remove(peer_id);
} else if second_stage_peers.len() < n_second_stage_peers {
if !first_stage_peers.contains(peer_id) {
second_stage_peers.insert(peer_id.clone());
second_stage_peers.insert(*peer_id);
}
} else {
break
Expand Down
4 changes: 2 additions & 2 deletions client/network-gossip/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,10 @@ mod tests {
let mut network = NoOpNetwork::default();

let peer_id = PeerId::random();
consensus.new_peer(&mut network, peer_id.clone(), ObservedRole::Full);
consensus.new_peer(&mut network, peer_id, ObservedRole::Full);
assert!(consensus.peers.contains_key(&peer_id));

consensus.peer_disconnected(&mut network, peer_id.clone());
consensus.peer_disconnected(&mut network, peer_id);
assert!(!consensus.peers.contains_key(&peer_id));
}

Expand Down
2 changes: 1 addition & 1 deletion client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<B: BlockT> Behaviour<B> {
request_response_protocols.push(state_request_protocol_config);
request_response_protocols.push(light_client_request_protocol_config);

Ok(Behaviour {
Ok(Self {
substrate,
peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key),
discovery: disco_config.finish(),
Expand Down
4 changes: 2 additions & 2 deletions client/network/src/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub struct Bitswap<B> {
impl<B: BlockT> Bitswap<B> {
/// Create a new instance of the bitswap protocol handler.
pub fn new(client: Arc<dyn Client<B>>) -> Self {
Bitswap { client, ready_blocks: Default::default() }
Self { client, ready_blocks: Default::default() }
}
}

Expand Down Expand Up @@ -305,7 +305,7 @@ impl<B: BlockT> NetworkBehaviour for Bitswap<B> {
>{
if let Some((peer_id, message)) = self.ready_blocks.pop_front() {
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
peer_id: peer_id.clone(),
peer_id,
handler: NotifyHandler::Any,
event: message,
})
Expand Down
44 changes: 22 additions & 22 deletions client/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ impl Role {
impl fmt::Display for Role {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Role::Full => write!(f, "FULL"),
Role::Light => write!(f, "LIGHT"),
Role::Authority { .. } => write!(f, "AUTHORITY"),
Self::Full => write!(f, "FULL"),
Self::Light => write!(f, "LIGHT"),
Self::Authority { .. } => write!(f, "AUTHORITY"),
}
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ pub struct ProtocolId(smallvec::SmallVec<[u8; 6]>);

impl<'a> From<&'a str> for ProtocolId {
fn from(bytes: &'a str) -> ProtocolId {
ProtocolId(bytes.as_bytes().into())
Self(bytes.as_bytes().into())
}
}

Expand Down Expand Up @@ -313,7 +313,7 @@ pub struct MultiaddrWithPeerId {
impl MultiaddrWithPeerId {
/// Concatenates the multiaddress and peer ID into one multiaddress containing both.
pub fn concat(&self) -> Multiaddr {
let proto = multiaddr::Protocol::P2p(From::from(self.peer_id.clone()));
let proto = multiaddr::Protocol::P2p(From::from(self.peer_id));
self.multiaddr.clone().with(proto)
}
}
Expand Down Expand Up @@ -360,26 +360,26 @@ pub enum ParseErr {
impl fmt::Display for ParseErr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ParseErr::MultiaddrParse(err) => write!(f, "{}", err),
ParseErr::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"),
ParseErr::PeerIdMissing => write!(f, "Peer id is missing from the address"),
Self::MultiaddrParse(err) => write!(f, "{}", err),
Self::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"),
Self::PeerIdMissing => write!(f, "Peer id is missing from the address"),
}
}
}

impl std::error::Error for ParseErr {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
ParseErr::MultiaddrParse(err) => Some(err),
ParseErr::InvalidPeerId => None,
ParseErr::PeerIdMissing => None,
Self::MultiaddrParse(err) => Some(err),
Self::InvalidPeerId => None,
Self::PeerIdMissing => None,
}
}
}

impl From<multiaddr::Error> for ParseErr {
fn from(err: multiaddr::Error) -> ParseErr {
ParseErr::MultiaddrParse(err)
Self::MultiaddrParse(err)
}
}

Expand All @@ -401,7 +401,7 @@ pub enum SyncMode {

impl Default for SyncMode {
fn default() -> Self {
SyncMode::Full
Self::Full
}
}

Expand Down Expand Up @@ -479,7 +479,7 @@ impl NetworkConfiguration {
node_key: NodeKeyConfig,
net_config_path: Option<PathBuf>,
) -> Self {
NetworkConfiguration {
Self {
net_config_path,
listen_addresses: Vec::new(),
public_addresses: Vec::new(),
Expand Down Expand Up @@ -548,7 +548,7 @@ pub struct SetConfig {

impl Default for SetConfig {
fn default() -> Self {
SetConfig {
Self {
in_peers: 25,
out_peers: 75,
reserved_nodes: Vec::new(),
Expand Down Expand Up @@ -585,7 +585,7 @@ pub struct NonDefaultSetConfig {
impl NonDefaultSetConfig {
/// Creates a new [`NonDefaultSetConfig`]. Zero slots and accepts only reserved nodes.
pub fn new(notifications_protocol: Cow<'static, str>, max_notification_size: u64) -> Self {
NonDefaultSetConfig {
Self {
notifications_protocol,
max_notification_size,
fallback_names: Vec::new(),
Expand Down Expand Up @@ -644,8 +644,8 @@ impl NonReservedPeerMode {
/// Attempt to parse the peer mode from a string.
pub fn parse(s: &str) -> Option<Self> {
match s {
"accept" => Some(NonReservedPeerMode::Accept),
"deny" => Some(NonReservedPeerMode::Deny),
"accept" => Some(Self::Accept),
"deny" => Some(Self::Deny),
_ => None,
}
}
Expand All @@ -662,7 +662,7 @@ pub enum NodeKeyConfig {

impl Default for NodeKeyConfig {
fn default() -> NodeKeyConfig {
NodeKeyConfig::Ed25519(Secret::New)
Self::Ed25519(Secret::New)
}
}

Expand All @@ -687,9 +687,9 @@ pub enum Secret<K> {
impl<K> fmt::Debug for Secret<K> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Secret::Input(_) => f.debug_tuple("Secret::Input").finish(),
Secret::File(path) => f.debug_tuple("Secret::File").field(path).finish(),
Secret::New => f.debug_tuple("Secret::New").finish(),
Self::Input(_) => f.debug_tuple("Secret::Input").finish(),
Self::File(path) => f.debug_tuple("Secret::File").field(path).finish(),
Self::New => f.debug_tuple("Secret::New").finish(),
}
}
}
Expand Down
Loading