Fix clippy lints

This commit is contained in:
Paul Hauner
2019-03-20 10:51:53 +11:00
parent 8f23aefb29
commit 84f373fcc2
13 changed files with 38 additions and 51 deletions

View File

@@ -71,7 +71,7 @@ impl BeaconBlock {
/// Note: performs a full tree-hash of `self.body`.
///
/// Spec v0.5.0
pub fn into_header(&self) -> BeaconBlockHeader {
pub fn block_header(&self) -> BeaconBlockHeader {
BeaconBlockHeader {
slot: self.slot,
previous_block_root: self.previous_block_root,
@@ -84,11 +84,11 @@ impl BeaconBlock {
/// Returns a "temporary" header, where the `state_root` is `spec.zero_hash`.
///
/// Spec v0.5.0
pub fn into_temporary_header(&self, spec: &ChainSpec) -> BeaconBlockHeader {
pub fn temporary_block_header(&self, spec: &ChainSpec) -> BeaconBlockHeader {
BeaconBlockHeader {
state_root: spec.zero_hash,
signature: spec.empty_signature.clone(),
..self.into_header()
..self.block_header()
}
}
}

View File

@@ -162,7 +162,7 @@ impl BeaconState {
latest_state_roots: vec![spec.zero_hash; spec.slots_per_historical_root],
latest_active_index_roots: vec![spec.zero_hash; spec.latest_active_index_roots_length],
latest_slashed_balances: vec![0; spec.latest_slashed_exit_length],
latest_block_header: BeaconBlock::empty(spec).into_temporary_header(spec),
latest_block_header: BeaconBlock::empty(spec).temporary_block_header(spec),
historical_roots: vec![],
/*
@@ -386,7 +386,8 @@ impl BeaconState {
spec: &ChainSpec,
) -> Result<(), BeaconStateError> {
let i = self.get_latest_block_roots_index(slot, spec)?;
Ok(self.latest_block_roots[i] = block_root)
self.latest_block_roots[i] = block_root;
Ok(())
}
/// Safely obtains the index for `latest_randao_mixes`
@@ -449,7 +450,8 @@ impl BeaconState {
spec: &ChainSpec,
) -> Result<(), Error> {
let i = self.get_randao_mix_index(epoch, spec)?;
Ok(self.latest_randao_mixes[i] = mix)
self.latest_randao_mixes[i] = mix;
Ok(())
}
/// Safely obtains the index for `latest_active_index_roots`, given some `epoch`.
@@ -492,7 +494,8 @@ impl BeaconState {
spec: &ChainSpec,
) -> Result<(), Error> {
let i = self.get_active_index_root_index(epoch, spec)?;
Ok(self.latest_active_index_roots[i] = index_root)
self.latest_active_index_roots[i] = index_root;
Ok(())
}
/// Replace `active_index_roots` with clones of `index_root`.
@@ -537,7 +540,8 @@ impl BeaconState {
spec: &ChainSpec,
) -> Result<(), Error> {
let i = self.get_latest_state_roots_index(slot, spec)?;
Ok(self.latest_state_roots[i] = state_root)
self.latest_state_roots[i] = state_root;
Ok(())
}
/// Safely obtains the index for `latest_slashed_balances`, given some `epoch`.
@@ -573,7 +577,8 @@ impl BeaconState {
spec: &ChainSpec,
) -> Result<(), Error> {
let i = self.get_slashed_balance_index(epoch, spec)?;
Ok(self.latest_slashed_balances[i] = balance)
self.latest_slashed_balances[i] = balance;
Ok(())
}
/// Generate a seed for the given `epoch`.

View File

@@ -304,7 +304,6 @@ impl EpochCrosslinkCommitteesBuilder {
for (i, slot) in self.epoch.slot_iter(spec.slots_per_epoch).enumerate() {
for j in (0..committees.len())
.into_iter()
.skip(i * committees_per_slot)
.take(committees_per_slot)
{

View File

@@ -33,7 +33,7 @@ impl RelativeEpoch {
/// Returns the `epoch` that `self` refers to, with respect to the `base` epoch.
///
/// Spec v0.5.0
pub fn into_epoch(&self, base: Epoch) -> Epoch {
pub fn into_epoch(self, base: Epoch) -> Epoch {
match self {
RelativeEpoch::Previous => base - 1,
RelativeEpoch::Current => base,

View File

@@ -214,7 +214,7 @@ impl TestingBeaconStateBuilder {
- spec.min_attestation_inclusion_delay;
let last_slot = std::cmp::min(state.slot.as_u64(), last_slot);
for slot in first_slot..last_slot + 1 {
for slot in first_slot..=last_slot {
let slot = Slot::from(slot);
let committees = state

View File

@@ -47,7 +47,7 @@ impl TestingDepositBuilder {
self.deposit
.deposit_data
.deposit_input
.withdrawal_credentials = withdrawal_credentials.clone();
.withdrawal_credentials = withdrawal_credentials;
self.deposit.deposit_data.deposit_input.proof_of_possession = self
.deposit