mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 06:14:38 +00:00
Appease arithmetic_side_effects
This commit is contained in:
@@ -1734,16 +1734,15 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
previous_epoch: Epoch,
|
||||
val_index: usize,
|
||||
) -> Result<bool, Error> {
|
||||
self.get_validator(val_index).map(|val| {
|
||||
val.is_active_at(previous_epoch)
|
||||
|| (val.slashed && previous_epoch + Epoch::new(1) < val.withdrawable_epoch)
|
||||
})
|
||||
let val = self.get_validator(val_index)?;
|
||||
Ok(val.is_active_at(previous_epoch)
|
||||
|| (val.slashed && previous_epoch.safe_add(Epoch::new(1))? < val.withdrawable_epoch))
|
||||
}
|
||||
|
||||
/// Passing `previous_epoch` to this function rather than computing it internally provides
|
||||
/// a tangible speed improvement in state processing.
|
||||
pub fn is_in_inactivity_leak(&self, previous_epoch: Epoch, spec: &ChainSpec) -> bool {
|
||||
(previous_epoch - self.finalized_checkpoint().epoch) > spec.min_epochs_to_inactivity_penalty
|
||||
pub fn is_in_inactivity_leak(&self, previous_epoch: Epoch, spec: &ChainSpec) -> Result<bool, safe_arith::ArithError> {
|
||||
Ok((previous_epoch.safe_sub(self.finalized_checkpoint().epoch)?) > spec.min_epochs_to_inactivity_penalty)
|
||||
}
|
||||
|
||||
/// Get the `SyncCommittee` associated with the next slot. Useful because sync committees
|
||||
|
||||
@@ -28,7 +28,7 @@ pub trait TestRandom {
|
||||
|
||||
impl<T> TestRandom for PhantomData<T> {
|
||||
fn random_for_test(_rng: &mut impl RngCore) -> Self {
|
||||
PhantomData::default()
|
||||
PhantomData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user