mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Directory Restructure (#1163)
* Move tests -> testing * Directory restructure * Update Cargo.toml during restructure * Update Makefile during restructure * Fix arbitrary path
This commit is contained in:
34
consensus/state_processing/src/common/mod.rs
Normal file
34
consensus/state_processing/src/common/mod.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
mod deposit_data_tree;
|
||||
mod get_attesting_indices;
|
||||
mod get_base_reward;
|
||||
mod get_indexed_attestation;
|
||||
mod initiate_validator_exit;
|
||||
mod slash_validator;
|
||||
|
||||
pub use deposit_data_tree::DepositDataTree;
|
||||
pub use get_attesting_indices::get_attesting_indices;
|
||||
pub use get_base_reward::get_base_reward;
|
||||
pub use get_indexed_attestation::get_indexed_attestation;
|
||||
pub use initiate_validator_exit::initiate_validator_exit;
|
||||
pub use slash_validator::slash_validator;
|
||||
|
||||
use safe_arith::{ArithError, SafeArith};
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
/// Increase the balance of a validator, erroring upon overflow, as per the spec.
|
||||
///
|
||||
/// Spec v0.11.2
|
||||
pub fn increase_balance<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
index: usize,
|
||||
delta: u64,
|
||||
) -> Result<(), ArithError> {
|
||||
state.balances[index].safe_add_assign(delta)
|
||||
}
|
||||
|
||||
/// Decrease the balance of a validator, saturating upon overflow, as per the spec.
|
||||
///
|
||||
/// Spec v0.11.2
|
||||
pub fn decrease_balance<E: EthSpec>(state: &mut BeaconState<E>, index: usize, delta: u64) {
|
||||
state.balances[index] = state.balances[index].saturating_sub(delta);
|
||||
}
|
||||
Reference in New Issue
Block a user