CommitteeCache.initialized: fail early if possible (#4556)
This commit is contained in:
parent
fcf51d691e
commit
b5e25aeb2f
@ -56,6 +56,11 @@ impl CommitteeCache {
|
|||||||
return Err(Error::ZeroSlotsPerEpoch);
|
return Err(Error::ZeroSlotsPerEpoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The use of `NonZeroUsize` reduces the maximum number of possible validators by one.
|
||||||
|
if state.validators().len() == usize::max_value() {
|
||||||
|
return Err(Error::TooManyValidators);
|
||||||
|
}
|
||||||
|
|
||||||
let active_validator_indices = get_active_validator_indices(state.validators(), epoch);
|
let active_validator_indices = get_active_validator_indices(state.validators(), epoch);
|
||||||
|
|
||||||
if active_validator_indices.is_empty() {
|
if active_validator_indices.is_empty() {
|
||||||
@ -75,11 +80,6 @@ impl CommitteeCache {
|
|||||||
)
|
)
|
||||||
.ok_or(Error::UnableToShuffle)?;
|
.ok_or(Error::UnableToShuffle)?;
|
||||||
|
|
||||||
// The use of `NonZeroUsize` reduces the maximum number of possible validators by one.
|
|
||||||
if state.validators().len() == usize::max_value() {
|
|
||||||
return Err(Error::TooManyValidators);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut shuffling_positions = vec![<_>::default(); state.validators().len()];
|
let mut shuffling_positions = vec![<_>::default(); state.validators().len()];
|
||||||
for (i, &v) in shuffling.iter().enumerate() {
|
for (i, &v) in shuffling.iter().enumerate() {
|
||||||
*shuffling_positions
|
*shuffling_positions
|
||||||
|
Loading…
Reference in New Issue
Block a user