Fix minor clippy lints in grandpa (#5988)

* grandpa: fix clippy lints about identity conversions

* grandpa: fix clippy lints about unwrap_or_default

* grandpa: fix clippy lints about explicit return

* grandpa: fix clippy lints about unnecessary intermediary

* grandpa: fix clippy lints about to_string

* grandpa: fix clippy lints about unused imports

* grandpa: fix clippy lints about increments

* grandpa: fix clippy lints about unnecessary matches

* grandpa: fix clippy lints about struct arguments

* Fix clippy::redundant_clone

* Fix clippy::clone_on_copy

* Fix clippy::or_fun_call

* Fix clippy::identity_conversion
This commit is contained in:
Jon Häggblad
2020-05-13 18:40:52 +02:00
committed by GitHub
parent 10492c0689
commit b99033368b
14 changed files with 53 additions and 58 deletions
@@ -61,7 +61,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
};
for signed in commit.precommits.iter() {
let mut current_hash = signed.precommit.target_hash.clone();
let mut current_hash = signed.precommit.target_hash;
loop {
if current_hash == commit.target_hash { break; }
@@ -71,7 +71,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
return error();
}
let parent_hash = current_header.parent_hash().clone();
let parent_hash = *current_header.parent_hash();
if votes_ancestries_hashes.insert(current_hash) {
votes_ancestries.push(current_header);
}
@@ -131,16 +131,16 @@ impl<Block: BlockT> GrandpaJustification<Block> {
let mut buf = Vec::new();
let mut visited_hashes = HashSet::new();
for signed in self.commit.precommits.iter() {
if let Err(_) = sp_finality_grandpa::check_message_signature_with_buffer(
if sp_finality_grandpa::check_message_signature_with_buffer(
&finality_grandpa::Message::Precommit(signed.precommit.clone()),
&signed.id,
&signed.signature,
self.round,
set_id,
&mut buf,
) {
).is_err() {
return Err(ClientError::BadJustification(
"invalid signature for precommit in grandpa justification".to_string()).into());
"invalid signature for precommit in grandpa justification".to_string()));
}
if self.commit.target_hash == signed.precommit.target_hash {
@@ -157,7 +157,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
},
_ => {
return Err(ClientError::BadJustification(
"invalid precommit ancestry proof in grandpa justification".to_string()).into());
"invalid precommit ancestry proof in grandpa justification".to_string()));
},
}
}
@@ -169,7 +169,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
if visited_hashes != ancestry_hashes {
return Err(ClientError::BadJustification(
"invalid precommit ancestries in grandpa justification with unused headers".to_string()).into());
"invalid precommit ancestries in grandpa justification with unused headers".to_string()));
}
Ok(())