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
@@ -27,13 +27,10 @@ pub(super) const LAST_PRUNE: &[u8] = b"session_historical_last_prune";
/// Derive the key used to store the list of validators
pub(super) fn derive_key<P: AsRef<[u8]>>(prefix: P, session_index: SessionIndex) -> Vec<u8> {
let prefix: &[u8] = prefix.as_ref();
session_index.using_encoded(|encoded_session_index| {
prefix
.into_iter()
.chain(b"/".into_iter())
.chain(encoded_session_index.into_iter())
.copied()
.collect::<Vec<u8>>()
let mut key = prefix.as_ref().to_owned();
key.push(b'/');
key.extend_from_slice(encoded_session_index);
key
})
}
+5 -6
View File
@@ -184,7 +184,7 @@ impl<
// (0% is never returned).
let progress = if now >= offset {
let current = (now - offset) % period.clone() + One::one();
Some(Permill::from_rational(current.clone(), period.clone()))
Some(Permill::from_rational(current, period))
} else {
Some(Permill::from_rational(now + One::one(), offset))
};
@@ -689,7 +689,6 @@ impl<T: Config> Pallet<T> {
if let Some(&(_, ref old_keys)) = now_session_keys.next() {
if old_keys != keys {
changed = true;
return
}
}
};
@@ -803,10 +802,10 @@ impl<T: Config> Pallet<T> {
let who = T::ValidatorIdOf::convert(account.clone())
.ok_or(Error::<T>::NoAssociatedValidatorId)?;
ensure!(frame_system::Pallet::<T>::can_inc_consumer(&account), Error::<T>::NoAccount);
ensure!(frame_system::Pallet::<T>::can_inc_consumer(account), Error::<T>::NoAccount);
let old_keys = Self::inner_set_keys(&who, keys)?;
if old_keys.is_none() {
let assertion = frame_system::Pallet::<T>::inc_consumers(&account).is_ok();
let assertion = frame_system::Pallet::<T>::inc_consumers(account).is_ok();
debug_assert!(assertion, "can_inc_consumer() returned true; no change since; qed");
}
@@ -866,7 +865,7 @@ impl<T: Config> Pallet<T> {
let key_data = old_keys.get_raw(*id);
Self::clear_key_owner(*id, key_data);
}
frame_system::Pallet::<T>::dec_consumers(&account);
frame_system::Pallet::<T>::dec_consumers(account);
Ok(())
}
@@ -949,6 +948,6 @@ impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::ValidatorId>
let i = Inner::find_author(digests)?;
let validators = <Pallet<T>>::validators();
validators.get(i as usize).map(|k| k.clone())
validators.get(i as usize).cloned()
}
}