mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Improve attester errors, move info -> helpers
- Ensured one can distingush between a committee error and an invalid validator index when using `validator_attesation_slot_and_shard`. - Renamed the `info.rs` file to `getters.rs`, for clarity.
This commit is contained in:
@@ -2,7 +2,6 @@ use crate::{
|
||||
beacon_state::{CommitteesError, EpochProcessingError},
|
||||
BeaconState, ChainSpec, Hash256,
|
||||
};
|
||||
use log::debug;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
@@ -43,17 +42,17 @@ impl BeaconState {
|
||||
&self,
|
||||
validator_index: usize,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(u64, u64, u64), CommitteesError> {
|
||||
) -> Result<Option<(u64, u64, u64)>, CommitteesError> {
|
||||
let mut result = None;
|
||||
for slot in self.get_current_epoch_boundaries(spec.epoch_length) {
|
||||
for (committee, shard) in self.get_crosslink_committees_at_slot(slot, spec)? {
|
||||
if let Some(committee_index) = committee.iter().position(|&i| i == validator_index)
|
||||
{
|
||||
result = Some(Ok((slot, shard, committee_index as u64)));
|
||||
result = Some((slot, shard, committee_index as u64));
|
||||
}
|
||||
}
|
||||
}
|
||||
result.unwrap()
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user