mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 20:11:22 +00:00
Clean up representation of ValidatorStatus
This commit is contained in:
parent
fa3d9bdb07
commit
1ff47720f1
@ -2,14 +2,14 @@ use super::bls::{Keypair, PublicKey};
|
|||||||
use super::{Address, Hash256};
|
use super::{Address, Hash256};
|
||||||
use std::convert;
|
use std::convert;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum ValidatorStatus {
|
pub enum ValidatorStatus {
|
||||||
PendingActivation = 0,
|
PendingActivation,
|
||||||
Active = 1,
|
Active,
|
||||||
PendingExit = 2,
|
PendingExit,
|
||||||
PendingWithdraw = 3,
|
PendingWithdraw,
|
||||||
Withdrawn = 5,
|
Withdrawn,
|
||||||
Penalized = 127,
|
Penalized,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl convert::From<u8> for ValidatorStatus {
|
impl convert::From<u8> for ValidatorStatus {
|
||||||
@ -59,7 +59,7 @@ impl ValidatorRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn status_is(&self, status: ValidatorStatus) -> bool {
|
pub fn status_is(&self, status: ValidatorStatus) -> bool {
|
||||||
self.status == status as u8
|
self.status == status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ pub fn update_validator_set(
|
|||||||
/*
|
/*
|
||||||
* Validator is pending activiation.
|
* Validator is pending activiation.
|
||||||
*/
|
*/
|
||||||
x if x == ValidatorStatus::PendingActivation => {
|
ValidatorStatus::PendingActivation => {
|
||||||
let new_total_changed = total_changed
|
let new_total_changed = total_changed
|
||||||
.checked_add(deposit_size_gwei)
|
.checked_add(deposit_size_gwei)
|
||||||
.ok_or(UpdateValidatorSetError::ArithmeticOverflow)?;
|
.ok_or(UpdateValidatorSetError::ArithmeticOverflow)?;
|
||||||
@ -82,7 +82,7 @@ pub fn update_validator_set(
|
|||||||
/*
|
/*
|
||||||
* Validator is pending exit.
|
* Validator is pending exit.
|
||||||
*/
|
*/
|
||||||
x if x == ValidatorStatus::PendingExit => {
|
ValidatorStatus::PendingExit => {
|
||||||
let new_total_changed = total_changed
|
let new_total_changed = total_changed
|
||||||
.checked_add(v.balance)
|
.checked_add(v.balance)
|
||||||
.ok_or(UpdateValidatorSetError::ArithmeticOverflow)?;
|
.ok_or(UpdateValidatorSetError::ArithmeticOverflow)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user