Apply some clippy lints (#11154)

* Apply some clippy hints

* Revert clippy ci changes

* Update client/cli/src/commands/generate.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/cli/src/commands/inspect_key.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/transactions.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/protocol.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Revert due to missing `or_default` function.

* Fix compilation and simplify code

* Undo change that corrupts benchmark.

* fix clippy

* Update client/service/test/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

remove leftovers!

* Update client/tracing/src/logging/directives.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/fork-tree/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* added needed ref

* Update frame/referenda/src/benchmarking.rs

* Simplify byte-vec creation

* let's just not overlap the ranges

* Correction

* cargo fmt

* Update utils/frame/benchmarking-cli/src/shared/stats.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
Falco Hirschenberger
2022-04-30 23:28:27 +02:00
committed by GitHub
parent a990473cf9
commit b581604aa7
368 changed files with 1927 additions and 2236 deletions
+20 -28
View File
@@ -195,7 +195,7 @@ where
// Private and public keys configuration.
let local_identity = params.network_config.node_key.clone().into_keypair()?;
let local_public = local_identity.public();
let local_peer_id = local_public.clone().to_peer_id();
let local_peer_id = local_public.to_peer_id();
info!(
target: "sub-libp2p",
"🏷 Local node identity is: {}",
@@ -248,7 +248,7 @@ where
Err(Error::DuplicateBootnode {
address: addr.clone(),
first_id: *peer_id,
second_id: other.0.clone(),
second_id: other.0,
})
} else {
Ok(())
@@ -644,7 +644,7 @@ where
.collect()
};
let peer_id = Swarm::<Behaviour<B, Client>>::local_peer_id(&swarm).to_base58();
let peer_id = Swarm::<Behaviour<B, Client>>::local_peer_id(swarm).to_base58();
let listened_addresses = swarm.listeners().cloned().collect();
let external_addresses = swarm.external_addresses().map(|r| &r.addr).cloned().collect();
@@ -664,7 +664,7 @@ where
.behaviour_mut()
.user_protocol_mut()
.peers_info()
.map(|(id, info)| (id.clone(), info.clone()))
.map(|(id, info)| (*id, info.clone()))
.collect()
}
@@ -753,7 +753,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
// `peers_notifications_sinks` mutex as soon as possible.
let sink = {
let peers_notifications_sinks = self.peers_notifications_sinks.lock();
if let Some(sink) = peers_notifications_sinks.get(&(target.clone(), protocol.clone())) {
if let Some(sink) = peers_notifications_sinks.get(&(target, protocol.clone())) {
sink.clone()
} else {
// Notification silently discarded, as documented.
@@ -1093,7 +1093,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
let _ = self
.to_worker
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id.clone(), addr));
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id, addr));
let _ = self.to_worker.unbounded_send(ServiceToWorkerMsg::AddReserved(peer_id));
Ok(())
}
@@ -1173,7 +1173,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
if !addr.is_empty() {
let _ = self
.to_worker
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id.clone(), addr));
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id, addr));
}
let _ = self
.to_worker
@@ -1227,7 +1227,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
if !addr.is_empty() {
let _ = self
.to_worker
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id.clone(), addr));
.unbounded_send(ServiceToWorkerMsg::AddKnownAddress(peer_id, addr));
}
let _ = self
.to_worker
@@ -1351,9 +1351,7 @@ pub struct NotificationSender {
impl NotificationSender {
/// Returns a future that resolves when the `NotificationSender` is ready to send a
/// notification.
pub async fn ready<'a>(
&'a self,
) -> Result<NotificationSenderReady<'a>, NotificationSenderError> {
pub async fn ready(&self) -> Result<NotificationSenderReady<'_>, NotificationSenderError> {
Ok(NotificationSenderReady {
ready: match self.sink.reserve_notification().await {
Ok(r) => r,
@@ -1771,7 +1769,7 @@ where
if let Some(metrics) = this.metrics.as_ref() {
metrics
.kademlia_random_queries_total
.with_label_values(&[&protocol.as_ref()])
.with_label_values(&[protocol.as_ref()])
.inc();
},
Poll::Ready(SwarmEvent::Behaviour(BehaviourOut::NotificationStreamOpened {
@@ -1790,7 +1788,7 @@ where
{
let mut peers_notifications_sinks = this.peers_notifications_sinks.lock();
let _previous_value = peers_notifications_sinks
.insert((remote.clone(), protocol.clone()), notifications_sink);
.insert((remote, protocol.clone()), notifications_sink);
debug_assert!(_previous_value.is_none());
}
this.event_streams.send(Event::NotificationStreamOpened {
@@ -1848,13 +1846,12 @@ where
.inc();
}
this.event_streams.send(Event::NotificationStreamClosed {
remote: remote.clone(),
remote,
protocol: protocol.clone(),
});
{
let mut peers_notifications_sinks = this.peers_notifications_sinks.lock();
let _previous_value =
peers_notifications_sinks.remove(&(remote.clone(), protocol));
let _previous_value = peers_notifications_sinks.remove(&(remote, protocol));
debug_assert!(_previous_value.is_some());
}
},
@@ -2117,10 +2114,7 @@ where
for (lower_ilog2_bucket_bound, num_entries) in buckets {
metrics
.kbuckets_num_nodes
.with_label_values(&[
&proto.as_ref(),
&lower_ilog2_bucket_bound.to_string(),
])
.with_label_values(&[proto.as_ref(), &lower_ilog2_bucket_bound.to_string()])
.set(num_entries as u64);
}
}
@@ -2128,7 +2122,7 @@ where
{
metrics
.kademlia_records_count
.with_label_values(&[&proto.as_ref()])
.with_label_values(&[proto.as_ref()])
.set(num_entries as u64);
}
for (proto, num_entries) in
@@ -2136,7 +2130,7 @@ where
{
metrics
.kademlia_records_sizes_total
.with_label_values(&[&proto.as_ref()])
.with_label_values(&[proto.as_ref()])
.set(num_entries as u64);
}
metrics
@@ -2211,12 +2205,10 @@ where
number: NumberFor<B>,
success: bool,
) {
self.protocol.behaviour_mut().user_protocol_mut().justification_import_result(
who,
hash.clone(),
number,
success,
);
self.protocol
.behaviour_mut()
.user_protocol_mut()
.justification_import_result(who, *hash, number, success);
}
fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>) {
self.protocol