From ab10cbbdb5ae6d706a59e454658ded89693b2061 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 24 Feb 2019 18:52:12 +1300 Subject: [PATCH] Fix clippy lints, small typos --- beacon_node/beacon_chain/src/beacon_chain.rs | 7 +------ .../state_processing/src/epoch_processable.rs | 1 - eth2/types/src/beacon_state.rs | 20 +++++++++---------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 9ee55e5a3..d0e7b7f8f 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -495,12 +495,7 @@ where // TODO: this is a first-in-best-dressed scenario that is not ideal; fork_choice should be // run instead. if self.head().beacon_block_root == parent_block_root { - self.update_canonical_head( - block.clone(), - block_root.clone(), - state.clone(), - state_root, - ); + self.update_canonical_head(block.clone(), block_root, state.clone(), state_root); // Update the local state variable. *self.state.write() = state.clone(); } diff --git a/eth2/state_processing/src/epoch_processable.rs b/eth2/state_processing/src/epoch_processable.rs index 409d40a2c..9b6c98c86 100644 --- a/eth2/state_processing/src/epoch_processable.rs +++ b/eth2/state_processing/src/epoch_processable.rs @@ -658,7 +658,6 @@ fn winning_root( continue; } - // TODO: `cargo fmt` makes this rather ugly; tidy up. let attesting_validator_indices = attestations .iter() .try_fold::<_, _, Result<_, BeaconStateError>>(vec![], |mut acc, a| { diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index 88f5422f8..e6dc9f6a6 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -222,10 +222,10 @@ impl BeaconState { ) -> Result<(), Error> { let cache_index = self.cache_index(relative_epoch); - if self.caches[cache_index].initialized == false { - self.force_build_epoch_cache(relative_epoch, spec) - } else { + if self.caches[cache_index].initialized { Ok(()) + } else { + self.force_build_epoch_cache(relative_epoch, spec) } } @@ -297,13 +297,13 @@ impl BeaconState { /// Returns the cache for some `RelativeEpoch`. Returns an error if the cache has not been /// initialized. - fn cache<'a>(&'a self, relative_epoch: RelativeEpoch) -> Result<&'a EpochCache, Error> { + fn cache(&self, relative_epoch: RelativeEpoch) -> Result<&EpochCache, Error> { let cache = &self.caches[self.cache_index(relative_epoch)]; - if cache.initialized == false { - Err(Error::EpochCacheUninitialized(relative_epoch)) - } else { + if cache.initialized { Ok(cache) + } else { + Err(Error::EpochCacheUninitialized(relative_epoch)) } } @@ -548,7 +548,7 @@ impl BeaconState { let next_epoch = self.next_epoch(spec); if epoch == current_epoch { - trace!("get_crosslink_committees_at_slot: current_epoch"); + trace!("get_committee_params_at_slot: current_epoch"); Ok(( self.get_current_epoch_committee_count(spec), self.current_epoch_seed, @@ -556,7 +556,7 @@ impl BeaconState { self.current_epoch_start_shard, )) } else if epoch == previous_epoch { - trace!("get_crosslink_committees_at_slot: previous_epoch"); + trace!("get_committee_params_at_slot: previous_epoch"); Ok(( self.get_previous_epoch_committee_count(spec), self.previous_epoch_seed, @@ -564,7 +564,7 @@ impl BeaconState { self.previous_epoch_start_shard, )) } else if epoch == next_epoch { - trace!("get_crosslink_committees_at_slot: next_epoch"); + trace!("get_committee_params_at_slot: next_epoch"); let current_committees_per_epoch = self.get_current_epoch_committee_count(spec); let epochs_since_last_registry_update = current_epoch - self.validator_registry_update_epoch;