Fix clippy warnings (#1385)

## Issue Addressed

NA

## Proposed Changes

Fixes most clippy warnings and ignores the rest of them, see issue #1388.
This commit is contained in:
blacktemplar
2020-07-23 14:18:00 +00:00
parent ba10c80633
commit 23a8f31f83
93 changed files with 396 additions and 396 deletions

View File

@@ -301,7 +301,7 @@ pub fn process_proposer_slashings<T: EthSpec>(
// We have to verify in series because an invalid block may contain multiple slashings
// for the same validator, and we need to correctly detect and reject that.
proposer_slashings
.into_iter()
.iter()
.enumerate()
.try_for_each(|(i, proposer_slashing)| {
verify_proposer_slashing(proposer_slashing, &state, verify_signatures, spec)
@@ -508,7 +508,7 @@ pub fn process_exits<T: EthSpec>(
) -> Result<(), BlockProcessingError> {
// Verify and apply each exit in series. We iterate in series because higher-index exits may
// become invalid due to the application of lower-index ones.
for (i, exit) in voluntary_exits.into_iter().enumerate() {
for (i, exit) in voluntary_exits.iter().enumerate() {
verify_exit(&state, exit, verify_signatures, spec).map_err(|e| e.into_with_index(i))?;
initiate_validator_exit(state, exit.message.validator_index as usize, spec)?;

View File

@@ -129,7 +129,7 @@ impl<'a, T: EthSpec> BlockProcessingBuilder<'a, T> {
signature: AggregateSignature::new(),
};
for (i, &validator_index) in committee.committee.into_iter().enumerate() {
for (i, &validator_index) in committee.committee.iter().enumerate() {
if should_sign(i, validator_index) {
attestation
.sign(

View File

@@ -83,7 +83,7 @@ where
/// add signatures, and the `verify`
pub fn new(state: &'a BeaconState<T>, get_pubkey: F, spec: &'a ChainSpec) -> Self {
Self {
get_pubkey: get_pubkey,
get_pubkey,
state,
spec,
sets: vec![],
@@ -129,7 +129,7 @@ where
.sets
.into_par_iter()
.chunks(num_chunks)
.map(|chunk| verify_signature_sets(chunk))
.map(verify_signature_sets)
.reduce(|| true, |current, this| current && this);
if result {

View File

@@ -314,8 +314,8 @@ pub fn deposit_pubkey_signature_message(
/// Returns the signature set for some set of deposit signatures, made with
/// `deposit_pubkey_signature_message`.
pub fn deposit_signature_set<'a>(
pubkey_signature_message: &'a (PublicKey, Signature, Vec<u8>),
pub fn deposit_signature_set(
pubkey_signature_message: &(PublicKey, Signature, Vec<u8>),
) -> SignatureSet {
let (pubkey, signature, message) = pubkey_signature_message;

View File

@@ -93,8 +93,8 @@ fn verify_casper_ffg_vote<T: EthSpec>(
verify!(
data.source == state.current_justified_checkpoint,
Invalid::WrongJustifiedCheckpoint {
state: state.current_justified_checkpoint.clone(),
attestation: data.source.clone(),
state: state.current_justified_checkpoint,
attestation: data.source,
is_current: true,
}
);
@@ -103,8 +103,8 @@ fn verify_casper_ffg_vote<T: EthSpec>(
verify!(
data.source == state.previous_justified_checkpoint,
Invalid::WrongJustifiedCheckpoint {
state: state.previous_justified_checkpoint.clone(),
attestation: data.source.clone(),
state: state.previous_justified_checkpoint,
attestation: data.source,
is_current: false,
}
);

View File

@@ -91,11 +91,11 @@ pub fn process_justification_and_finalization<T: EthSpec>(
let previous_epoch = state.previous_epoch();
let current_epoch = state.current_epoch();
let old_previous_justified_checkpoint = state.previous_justified_checkpoint.clone();
let old_current_justified_checkpoint = state.current_justified_checkpoint.clone();
let old_previous_justified_checkpoint = state.previous_justified_checkpoint;
let old_current_justified_checkpoint = state.current_justified_checkpoint;
// Process justifications
state.previous_justified_checkpoint = state.current_justified_checkpoint.clone();
state.previous_justified_checkpoint = state.current_justified_checkpoint;
state.justification_bits.shift_up(1)?;
if total_balances

View File

@@ -21,11 +21,12 @@ pub fn per_slot_processing<T: EthSpec>(
) -> Result<Option<EpochProcessingSummary>, Error> {
cache_state(state, state_root)?;
let mut summary = None;
if state.slot > spec.genesis_slot && (state.slot + 1) % T::slots_per_epoch() == 0 {
summary = Some(per_epoch_processing(state, spec)?);
}
let summary = if state.slot > spec.genesis_slot && (state.slot + 1) % T::slots_per_epoch() == 0
{
Some(per_epoch_processing(state, spec)?)
} else {
None
};
state.slot += 1;