Fix clippy lints, small typos

This commit is contained in:
Paul Hauner 2019-02-24 18:52:12 +13:00
parent c49f425fe8
commit ab10cbbdb5
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
3 changed files with 11 additions and 17 deletions

View File

@ -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();
}

View File

@ -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| {

View File

@ -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;