Move advance_slot
to its own file.
This commit is contained in:
parent
db230475d7
commit
942ef4b002
@ -4,7 +4,6 @@ use types::{beacon_state::SlotProcessingError, BeaconBlock, BeaconState, Hash256
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
PastSlot,
|
|
||||||
SlotProcessingError(SlotProcessingError),
|
SlotProcessingError(SlotProcessingError),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,17 +31,6 @@ where
|
|||||||
pub fn head(&self) -> RwLockReadGuard<CheckPoint> {
|
pub fn head(&self) -> RwLockReadGuard<CheckPoint> {
|
||||||
self.canonical_head.read()
|
self.canonical_head.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn advance_state(&self, slot: u64) -> Result<(), SlotProcessingError> {
|
|
||||||
let state_slot = self.state.read().slot;
|
|
||||||
let head_block_root = self.head().beacon_block_root;
|
|
||||||
for _ in state_slot..slot {
|
|
||||||
self.state
|
|
||||||
.write()
|
|
||||||
.per_slot_processing(head_block_root.clone(), &self.spec)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SlotProcessingError> for Error {
|
impl From<SlotProcessingError> for Error {
|
||||||
|
@ -10,7 +10,7 @@ pub mod dump;
|
|||||||
mod finalized_head;
|
mod finalized_head;
|
||||||
mod info;
|
mod info;
|
||||||
mod lmd_ghost;
|
mod lmd_ghost;
|
||||||
// mod state_transition;
|
mod state;
|
||||||
|
|
||||||
use self::attestation_targets::AttestationTargets;
|
use self::attestation_targets::AttestationTargets;
|
||||||
use self::block_graph::BlockGraph;
|
use self::block_graph::BlockGraph;
|
||||||
|
25
beacon_node/beacon_chain/src/state.rs
Normal file
25
beacon_node/beacon_chain/src/state.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use crate::{BeaconChain, ClientDB, SlotClock};
|
||||||
|
use types::beacon_state::SlotProcessingError;
|
||||||
|
|
||||||
|
impl<T, U> BeaconChain<T, U>
|
||||||
|
where
|
||||||
|
T: ClientDB,
|
||||||
|
U: SlotClock,
|
||||||
|
{
|
||||||
|
/// Advance the `self.state` `BeaconState` to the supplied slot.
|
||||||
|
///
|
||||||
|
/// This will perform per_slot and per_epoch processing as required.
|
||||||
|
///
|
||||||
|
/// The `previous_block_root` will be set to the root of the current head block (as determined
|
||||||
|
/// by the fork-choice rule).
|
||||||
|
pub fn advance_state(&self, slot: u64) -> Result<(), SlotProcessingError> {
|
||||||
|
let state_slot = self.state.read().slot;
|
||||||
|
let head_block_root = self.head().beacon_block_root;
|
||||||
|
for _ in state_slot..slot {
|
||||||
|
self.state
|
||||||
|
.write()
|
||||||
|
.per_slot_processing(head_block_root.clone(), &self.spec)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user