Fix clippy warnings (#813)

* Clippy account manager

* Clippy account_manager

* Clippy beacon_node/beacon_chain

* Clippy beacon_node/client

* Clippy beacon_node/eth1

* Clippy beacon_node/eth2-libp2p

* Clippy beacon_node/genesis

* Clippy beacon_node/network

* Clippy beacon_node/rest_api

* Clippy beacon_node/src

* Clippy beacon_node/store

* Clippy eth2/lmd_ghost

* Clippy eth2/operation_pool

* Clippy eth2/state_processing

* Clippy eth2/types

* Clippy eth2/utils/bls

* Clippy eth2/utils/cahced_tree_hash

* Clippy eth2/utils/deposit_contract

* Clippy eth2/utils/eth2_interop_keypairs

* Clippy eth2/utils/eth2_testnet_config

* Clippy eth2/utils/lighthouse_metrics

* Clippy eth2/utils/ssz

* Clippy eth2/utils/ssz_types

* Clippy eth2/utils/tree_hash_derive

* Clippy lcli

* Clippy tests/beacon_chain_sim

* Clippy validator_client

* Cargo fmt
This commit is contained in:
pscott
2020-01-21 11:38:56 +04:00
committed by Age Manning
parent 1abb964652
commit 7396cd2cab
78 changed files with 387 additions and 416 deletions

View File

@@ -8,6 +8,7 @@ use rand::prelude::*;
use slog::{crit, debug, error, trace, Logger};
use ssz_derive::{Decode, Encode};
use state_processing::per_block_processing::get_new_eth1_data;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::iter::DoubleEndedIterator;
use std::iter::FromIterator;
@@ -343,8 +344,7 @@ impl<T: EthSpec, S: Store<T>> Eth1ChainBackend<T, S> for CachingEth1Backend<T, S
.iter()
.rev()
.skip_while(|eth1_block| eth1_block.timestamp > voting_period_start_seconds)
.skip(eth1_follow_distance as usize)
.next()
.nth(eth1_follow_distance as usize)
.map(|block| {
trace!(
self.log,
@@ -392,21 +392,21 @@ impl<T: EthSpec, S: Store<T>> Eth1ChainBackend<T, S> for CachingEth1Backend<T, S
state.eth1_data.deposit_count
};
if deposit_index > deposit_count {
Err(Error::DepositIndexTooHigh)
} else if deposit_index == deposit_count {
Ok(vec![])
} else {
let next = deposit_index;
let last = std::cmp::min(deposit_count, next + T::MaxDeposits::to_u64());
match deposit_index.cmp(&deposit_count) {
Ordering::Greater => Err(Error::DepositIndexTooHigh),
Ordering::Equal => Ok(vec![]),
Ordering::Less => {
let next = deposit_index;
let last = std::cmp::min(deposit_count, next + T::MaxDeposits::to_u64());
self.core
.deposits()
.read()
.cache
.get_deposits(next, last, deposit_count, DEPOSIT_TREE_DEPTH)
.map_err(|e| Error::BackendError(format!("Failed to get deposits: {:?}", e)))
.map(|(_deposit_root, deposits)| deposits)
self.core
.deposits()
.read()
.cache
.get_deposits(next, last, deposit_count, DEPOSIT_TREE_DEPTH)
.map_err(|e| Error::BackendError(format!("Failed to get deposits: {:?}", e)))
.map(|(_deposit_root, deposits)| deposits)
}
}
}
@@ -775,7 +775,7 @@ mod test {
let deposits_for_inclusion = eth1_chain
.deposits_for_block_inclusion(&state, &random_eth1_data(), spec)
.expect(&format!("should find deposit for {}", i));
.unwrap_or_else(|_| panic!("should find deposit for {}", i));
let expected_len =
std::cmp::min(i - initial_deposit_index, max_deposits as usize);
@@ -853,7 +853,7 @@ mod test {
state.slot = Slot::new(period * 1_000 + period / 2);
// Add 50% of the votes so a lookup is required.
for _ in 0..period / 2 + 1 {
for _ in 0..=period / 2 {
state
.eth1_data_votes
.push(random_eth1_data())
@@ -932,7 +932,7 @@ mod test {
state.slot = Slot::new(period / 2);
// Add 50% of the votes so a lookup is required.
for _ in 0..period / 2 + 1 {
for _ in 0..=period / 2 {
state
.eth1_data_votes
.push(random_eth1_data())
@@ -1090,7 +1090,7 @@ mod test {
eth1_block.number,
*new_eth1_data
.get(&eth1_block.clone().eth1_data().unwrap())
.expect(&format!(
.unwrap_or_else(|| panic!(
"new_eth1_data should have expected block #{}",
eth1_block.number
))
@@ -1135,8 +1135,8 @@ mod test {
let votes = collect_valid_votes(
&state,
HashMap::from_iter(new_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.clone().into_iter()),
HashMap::from_iter(new_eth1_data.into_iter()),
HashMap::from_iter(all_eth1_data.into_iter()),
);
assert_eq!(
votes.len(),
@@ -1164,7 +1164,7 @@ mod test {
let votes = collect_valid_votes(
&state,
HashMap::from_iter(new_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.into_iter()),
);
assert_votes!(
votes,
@@ -1196,8 +1196,8 @@ mod test {
let votes = collect_valid_votes(
&state,
HashMap::from_iter(new_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.clone().into_iter()),
HashMap::from_iter(new_eth1_data.into_iter()),
HashMap::from_iter(all_eth1_data.into_iter()),
);
assert_votes!(
votes,
@@ -1230,12 +1230,12 @@ mod test {
.expect("should have some eth1 data")
.clone();
state.eth1_data_votes = vec![non_new_eth1_data.0.clone()].into();
state.eth1_data_votes = vec![non_new_eth1_data.0].into();
let votes = collect_valid_votes(
&state,
HashMap::from_iter(new_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.clone().into_iter()),
HashMap::from_iter(new_eth1_data.into_iter()),
HashMap::from_iter(all_eth1_data.into_iter()),
);
assert_votes!(
@@ -1268,8 +1268,8 @@ mod test {
let votes = collect_valid_votes(
&state,
HashMap::from_iter(new_eth1_data.clone().into_iter()),
HashMap::from_iter(all_eth1_data.clone().into_iter()),
HashMap::from_iter(new_eth1_data.into_iter()),
HashMap::from_iter(all_eth1_data.into_iter()),
);
assert_votes!(