Move get_active_validator_indices to state

This commit is contained in:
Paul Hauner
2019-03-19 09:09:57 +11:00
parent 4c4952e71b
commit 37b8e9f39a
17 changed files with 57 additions and 239 deletions

View File

@@ -10,10 +10,7 @@ use db::{
use log::{debug, trace};
use std::collections::HashMap;
use std::sync::Arc;
use types::{
validator_registry::get_active_validator_indices, BeaconBlock, ChainSpec, Hash256, Slot,
SlotHeight,
};
use types::{BeaconBlock, ChainSpec, Hash256, Slot, SlotHeight};
//TODO: Pruning - Children
//TODO: Handle Syncing
@@ -93,10 +90,8 @@ where
.get_deserialized(&state_root)?
.ok_or_else(|| ForkChoiceError::MissingBeaconState(*state_root))?;
let active_validator_indices = get_active_validator_indices(
&current_state.validator_registry[..],
block_slot.epoch(spec.slots_per_epoch),
);
let active_validator_indices =
current_state.get_active_validator_indices(block_slot.epoch(spec.slots_per_epoch));
for index in active_validator_indices {
let balance = std::cmp::min(

View File

@@ -10,10 +10,7 @@ use log::{debug, trace};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::sync::Arc;
use types::{
validator_registry::get_active_validator_indices, BeaconBlock, ChainSpec, Hash256, Slot,
SlotHeight,
};
use types::{BeaconBlock, ChainSpec, Hash256, Slot, SlotHeight};
//TODO: Pruning - Children
//TODO: Handle Syncing
@@ -93,10 +90,8 @@ where
.get_deserialized(&state_root)?
.ok_or_else(|| ForkChoiceError::MissingBeaconState(*state_root))?;
let active_validator_indices = get_active_validator_indices(
&current_state.validator_registry[..],
block_slot.epoch(spec.slots_per_epoch),
);
let active_validator_indices =
current_state.get_active_validator_indices(block_slot.epoch(spec.slots_per_epoch));
for index in active_validator_indices {
let balance = std::cmp::min(

View File

@@ -8,9 +8,7 @@ use db::{
use log::{debug, trace};
use std::collections::HashMap;
use std::sync::Arc;
use types::{
validator_registry::get_active_validator_indices, BeaconBlock, ChainSpec, Hash256, Slot,
};
use types::{BeaconBlock, ChainSpec, Hash256, Slot};
//TODO: Pruning and syncing
@@ -61,10 +59,8 @@ where
.get_deserialized(&state_root)?
.ok_or_else(|| ForkChoiceError::MissingBeaconState(*state_root))?;
let active_validator_indices = get_active_validator_indices(
&current_state.validator_registry[..],
block_slot.epoch(spec.slots_per_epoch),
);
let active_validator_indices =
current_state.get_active_validator_indices(block_slot.epoch(spec.slots_per_epoch));
for index in active_validator_indices {
let balance = std::cmp::min(