Implement fixes from PR review

This commit is contained in:
Paul Hauner 2019-06-24 15:31:36 +10:00
parent 3a196f3fdc
commit 8afe8b3569
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
3 changed files with 5 additions and 8 deletions

View File

@ -87,7 +87,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
start_state
.validator_registry
.get(validator_index)
.and_then(|v| Some(v.effective_balance))
.map(|v| v.effective_balance)
};
self.backend

View File

@ -33,7 +33,7 @@ fn fork() {
let honest_fork_blocks = delay + 1;
let faulty_fork_blocks = delay + 2;
// Build an initial chain were all validators agree.
// Build an initial chain where all validators agree.
harness.extend_chain(
initial_blocks,
BlockStrategy::OnCanonicalHead,

View File

@ -586,13 +586,10 @@ impl<T: EthSpec> BeaconState<T> {
/// Gets the oldest (earliest slot) state root.
///
/// Spec v0.5.1
/// Spec v0.6.3
pub fn get_oldest_state_root(&self) -> Result<&Hash256, Error> {
let lookback = std::cmp::min(
self.slot - Slot::from(self.latest_state_roots.len()),
self.slot,
);
let i = self.get_latest_state_roots_index(self.slot - lookback)?;
let i = self
.get_latest_state_roots_index(self.slot - Slot::from(self.latest_state_roots.len()))?;
Ok(&self.latest_state_roots[i])
}