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
@@ -294,7 +294,7 @@ where
}
}
let number = block.header.number().clone();
let number = *(block.header.number());
let maybe_change = self.check_new_change(
&block.header,
hash,
@@ -326,7 +326,7 @@ where
guard.as_mut().add_pending_change(
change,
&is_descendent_of,
).map_err(|e| ConsensusError::from(ConsensusError::ClientImport(e.to_string())))?;
).map_err(|e| ConsensusError::ClientImport(e.to_string()))?;
}
let applied_changes = {
@@ -417,14 +417,14 @@ impl<BE, Block: BlockT, Client, SC> BlockImport<Block>
new_cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
) -> Result<ImportResult, Self::Error> {
let hash = block.post_hash();
let number = block.header.number().clone();
let number = *block.header.number();
// early exit if block already in chain, otherwise the check for
// authority changes will error when trying to re-import a change block
match self.inner.status(BlockId::Hash(hash)) {
Ok(BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain),
Ok(BlockStatus::Unknown) => {},
Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()),
Err(e) => return Err(ConsensusError::ClientImport(e.to_string())),
}
// on initial sync we will restrict logging under info to avoid spam.
@@ -456,7 +456,7 @@ impl<BE, Block: BlockT, Client, SC> BlockImport<Block>
e,
);
pending_changes.revert();
return Err(ConsensusError::ClientImport(e.to_string()).into());
return Err(ConsensusError::ClientImport(e.to_string()));
},
}
};
@@ -466,7 +466,7 @@ impl<BE, Block: BlockT, Client, SC> BlockImport<Block>
// Send the pause signal after import but BEFORE sending a `ChangeAuthorities` message.
if do_pause {
let _ = self.send_voter_commands.unbounded_send(
VoterCommand::Pause(format!("Forced change scheduled after inactivity"))
VoterCommand::Pause("Forced change scheduled after inactivity".to_string())
);
}
@@ -633,7 +633,7 @@ where
);
let justification = match justification {
Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()),
Err(e) => return Err(ConsensusError::ClientImport(e.to_string())),
Ok(justification) => justification,
};
@@ -668,7 +668,7 @@ where
Error::Client(error) => ConsensusError::ClientImport(error.to_string()),
Error::Safety(error) => ConsensusError::ClientImport(error),
Error::Timer(error) => ConsensusError::ClientImport(error.to_string()),
}.into());
});
},
Ok(_) => {
assert!(!enacts_change, "returns Ok when no authority set change should be enacted; qed;");