Fix clippy lints

This commit is contained in:
Paul Hauner 2019-05-09 13:35:00 +10:00
parent 0ac278f44d
commit 2a938f2fd5
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
13 changed files with 20 additions and 23 deletions

View File

@ -191,7 +191,6 @@ where
count: usize,
skip: usize,
) -> Result<Vec<Hash256>, Error> {
let spec = &self.spec;
let step_by = Slot::from(skip + 1);
let mut roots: Vec<Hash256> = vec![];

View File

@ -1,16 +1,13 @@
use crate::ClientConfig;
use crate::{ArcBeaconChain, ClientConfig};
use beacon_chain::{
db::{ClientDB, DiskDB, MemoryDB},
fork_choice::BitwiseLMDGhost,
initialise,
slot_clock::{SlotClock, SystemTimeSlotClock},
BeaconChain,
};
use fork_choice::ForkChoice;
use types::{BeaconStateTypes, FewValidatorsStateTypes, FoundationStateTypes};
use std::sync::Arc;
pub trait ClientTypes {
type DB: ClientDB + 'static;
type SlotClock: SlotClock + 'static;
@ -19,7 +16,7 @@ pub trait ClientTypes {
fn initialise_beacon_chain(
config: &ClientConfig,
) -> Arc<BeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>>;
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>;
}
pub struct StandardClientType;
@ -32,7 +29,7 @@ impl ClientTypes for StandardClientType {
fn initialise_beacon_chain(
config: &ClientConfig,
) -> Arc<BeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
initialise::initialise_beacon_chain(&config.spec, Some(&config.db_name))
}
}
@ -47,7 +44,7 @@ impl ClientTypes for TestingClientType {
fn initialise_beacon_chain(
config: &ClientConfig,
) -> Arc<BeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
initialise::initialise_test_beacon_chain(&config.spec, None)
}
}

View File

@ -22,13 +22,15 @@ use tokio::runtime::TaskExecutor;
use tokio::timer::Interval;
use types::BeaconStateTypes;
type ArcBeaconChain<D, S, F, B> = Arc<BeaconChain<D, S, F, B>>;
/// Main beacon node client service. This provides the connection and initialisation of the clients
/// sub-services in multiple threads.
pub struct Client<T: ClientTypes> {
/// Configuration for the lighthouse client.
_config: ClientConfig,
/// The beacon chain for the running client.
_beacon_chain: Arc<BeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::BeaconStateTypes>>,
_beacon_chain: ArcBeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::BeaconStateTypes>,
/// Reference to the network service.
pub network: Arc<NetworkService<T::BeaconStateTypes>>,
/// Signal to terminate the RPC server.

View File

@ -97,7 +97,7 @@ impl ClientDB for DiskDB {
None => Err(DBError {
message: "Unknown column".to_string(),
}),
Some(handle) => self.db.put_cf(handle, key, val).map_err(|e| e.into()),
Some(handle) => self.db.put_cf(handle, key, val).map_err(Into::into),
}
}

View File

@ -2,7 +2,7 @@ use super::STATES_DB_COLUMN as DB_COLUMN;
use super::{ClientDB, DBError};
use ssz::decode;
use std::sync::Arc;
use types::{BeaconState, BeaconStateTypes, FoundationBeaconState, Hash256};
use types::{BeaconState, BeaconStateTypes, Hash256};
pub struct BeaconStateStore<T>
where
@ -43,7 +43,7 @@ mod tests {
use ssz::ssz_encode;
use std::sync::Arc;
use types::test_utils::{SeedableRng, TestRandom, XorShiftRng};
use types::Hash256;
use types::{FoundationBeaconState, Hash256};
test_crud_for_store!(BeaconStateStore, DB_COLUMN);

View File

@ -300,7 +300,7 @@ impl NetworkContext {
let next_id = self
.outgoing_request_ids
.entry(peer_id.clone())
.and_modify(|id| id.increment())
.and_modify(RequestId::increment)
.or_insert_with(|| RequestId::from(1));
next_id.previous()

View File

@ -175,11 +175,7 @@ impl<T: BeaconStateTypes> OperationPool<T> {
/// Total number of attestations in the pool, including attestations for the same data.
pub fn num_attestations(&self) -> usize {
self.attestations
.read()
.values()
.map(|atts| atts.len())
.sum()
self.attestations.read().values().map(Vec::len).sum()
}
/// Get a list of attestations for inclusion in a block.

View File

@ -817,7 +817,7 @@ impl<T: BeaconStateTypes> BeaconState<T> {
self.tree_hash_cache
.tree_hash_root()
.and_then(|b| Ok(Hash256::from_slice(b)))
.map_err(|e| e.into())
.map_err(Into::into)
}
}

View File

@ -226,7 +226,7 @@ impl Decodable for BooleanBitfield {
// as the BitVec library and the hex-parser use opposing bit orders.
fn reverse_bit_order(mut bytes: Vec<u8>) -> Vec<u8> {
bytes.reverse();
bytes.into_iter().map(|b| b.swap_bits()).collect()
bytes.into_iter().map(LookupReverse::swap_bits).collect()
}
impl Serialize for BooleanBitfield {

View File

@ -22,6 +22,10 @@ impl<T, N: Unsigned> FixedLenVec<T, N> {
self.vec.len()
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn capacity() -> usize {
N::to_usize()
}

View File

@ -35,7 +35,7 @@ pub fn merkle_root(values: &[Vec<u8>]) -> Option<Vec<u8>> {
}
// the root hash will be at index 1
return Some(o[1].clone());
Some(o[1].clone())
}
#[cfg(test)]

View File

@ -51,7 +51,7 @@ impl<U: BeaconNodeDuties, S: Signer + Display> DutiesManager<U, S> {
///
/// be a wall-clock (e.g., system time, remote server time, etc.).
fn update(&self, epoch: Epoch) -> Result<UpdateOutcome, Error> {
let public_keys: Vec<PublicKey> = self.signers.iter().map(|s| s.to_public()).collect();
let public_keys: Vec<PublicKey> = self.signers.iter().map(Signer::to_public).collect();
let duties = self.beacon_node.request_duties(epoch, &public_keys)?;
{
// If these duties were known, check to see if they're updates or identical.

View File

@ -31,7 +31,6 @@ use tokio::prelude::*;
use tokio::runtime::Builder;
use tokio::timer::Interval;
use tokio_timer::clock::Clock;
use types::test_utils::generate_deterministic_keypairs;
use types::{ChainSpec, Epoch, Fork, Slot};
/// A fixed amount of time after a slot to perform operations. This gives the node time to complete