From 1ff47720f1d5b1f62bca144da15f4c4a556cbc2c Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Wed, 12 Dec 2018 19:05:32 -0800 Subject: [PATCH] Clean up representation of ValidatorStatus --- beacon_chain/types/src/validator_record.rs | 16 ++++++++-------- beacon_chain/validator_change/src/lib.rs | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/beacon_chain/types/src/validator_record.rs b/beacon_chain/types/src/validator_record.rs index d08f77c53..537c91723 100644 --- a/beacon_chain/types/src/validator_record.rs +++ b/beacon_chain/types/src/validator_record.rs @@ -2,14 +2,14 @@ use super::bls::{Keypair, PublicKey}; use super::{Address, Hash256}; use std::convert; -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Clone)] pub enum ValidatorStatus { - PendingActivation = 0, - Active = 1, - PendingExit = 2, - PendingWithdraw = 3, - Withdrawn = 5, - Penalized = 127, + PendingActivation, + Active, + PendingExit, + PendingWithdraw, + Withdrawn, + Penalized, } impl convert::From for ValidatorStatus { @@ -59,7 +59,7 @@ impl ValidatorRecord { } pub fn status_is(&self, status: ValidatorStatus) -> bool { - self.status == status as u8 + self.status == status } } diff --git a/beacon_chain/validator_change/src/lib.rs b/beacon_chain/validator_change/src/lib.rs index a2299b930..a2d9daeff 100644 --- a/beacon_chain/validator_change/src/lib.rs +++ b/beacon_chain/validator_change/src/lib.rs @@ -62,7 +62,7 @@ pub fn update_validator_set( /* * Validator is pending activiation. */ - x if x == ValidatorStatus::PendingActivation => { + ValidatorStatus::PendingActivation => { let new_total_changed = total_changed .checked_add(deposit_size_gwei) .ok_or(UpdateValidatorSetError::ArithmeticOverflow)?; @@ -82,7 +82,7 @@ pub fn update_validator_set( /* * Validator is pending exit. */ - x if x == ValidatorStatus::PendingExit => { + ValidatorStatus::PendingExit => { let new_total_changed = total_changed .checked_add(v.balance) .ok_or(UpdateValidatorSetError::ArithmeticOverflow)?;