Correct process_attestation error handling.

This commit is contained in:
Grant Wuerker
2019-07-24 18:03:48 +02:00
parent b2471eca49
commit 51645aa9af
4 changed files with 41 additions and 11 deletions

View File

@@ -166,24 +166,24 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
Ok(())
}
/// Determines whether or not the given attestation contains a latest messages.
pub fn should_process_attestation(&self, state: &BeaconState<T::EthSpec>, attestation: &Attestation) -> bool {
/// Determines whether or not the given attestation contains a latest message.
pub fn should_process_attestation(&self, state: &BeaconState<T::EthSpec>, attestation: &Attestation) -> Result<bool> {
let validator_indices = common::get_attesting_indices_unsorted(
state,
&attestation.data,
&attestation.aggregation_bitfield,
).unwrap();
)?;
let target_slot = attestation.data.target_epoch.start_slot(T::EthSpec::slots_per_epoch());
validator_indices
Ok(validator_indices
.iter()
.find(|&&v| {
match self.backend.latest_message(v) {
Some((_, slot)) => target_slot > slot,
None => true
}
}).is_some()
}).is_some())
}
/// Inform the fork choice that the given block (and corresponding root) have been finalized so
@@ -218,3 +218,4 @@ impl From<String> for Error {
Error::BackendError(e)
}
}