Fix clippy lints in lmd_ghost

This commit is contained in:
Paul Hauner 2019-02-13 09:26:29 +11:00
parent 4824b43808
commit 61bbbab33d
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -57,16 +57,16 @@ where
let start = self let start = self
.block_store .block_store
.get_reader(&start_hash)? .get_reader(&start_hash)?
.ok_or(Error::MissingBeaconBlock(*start_hash))?; .ok_or_else(|| Error::MissingBeaconBlock(*start_hash))?;
let start_state_root = start.state_root(); let start_state_root = start.state_root();
let state = self let state = self
.state_store .state_store
.get_reader(&start_state_root)? .get_reader(&start_state_root)?
.ok_or(Error::MissingBeaconState(start_state_root))? .ok_or_else(|| Error::MissingBeaconState(start_state_root))?
.into_beacon_state() .into_beacon_state()
.ok_or(Error::InvalidBeaconState(start_state_root))?; .ok_or_else(|| Error::InvalidBeaconState(start_state_root))?;
let active_validator_indices = get_active_validator_indices( let active_validator_indices = get_active_validator_indices(
&state.validator_registry, &state.validator_registry,
@ -90,7 +90,7 @@ where
&self.block_graph.leaves(), &self.block_graph.leaves(),
)?; )?;
if child_hashes_and_slots.len() == 0 { if child_hashes_and_slots.is_empty() {
break; break;
} }
@ -126,7 +126,7 @@ fn get_vote_count<T: ClientDB>(
for target in attestation_targets { for target in attestation_targets {
let (root_at_slot, _) = block_store let (root_at_slot, _) = block_store
.block_at_slot(&block_root, slot)? .block_at_slot(&block_root, slot)?
.ok_or(Error::MissingBeaconBlock(*block_root))?; .ok_or_else(|| Error::MissingBeaconBlock(*block_root))?;
if root_at_slot == *target { if root_at_slot == *target {
count += 1; count += 1;
} }
@ -165,7 +165,7 @@ fn get_child_hashes_and_slots<T: ClientDB>(
break; break;
} }
current_hash = parent_root.clone(); current_hash = parent_root;
} else { } else {
return Err(Error::MissingBeaconBlock(current_hash)); return Err(Error::MissingBeaconBlock(current_hash));
} }