Update beacon_chain as per test bugs

This commit is contained in:
Paul Hauner
2019-01-25 11:30:06 +11:00
parent 643fc20063
commit f4f5b3a13c
9 changed files with 188 additions and 86 deletions

View File

@@ -0,0 +1,34 @@
use crate::{BeaconChain, CheckPoint, ClientDB, SlotClock};
use std::sync::RwLockReadGuard;
use types::{BeaconBlock, BeaconState, Hash256};
impl<T, U> BeaconChain<T, U>
where
T: ClientDB,
U: SlotClock,
{
pub fn update_finalized_head(
&self,
new_beacon_block: BeaconBlock,
new_beacon_block_root: Hash256,
new_beacon_state: BeaconState,
new_beacon_state_root: Hash256,
) {
let mut finalized_head = self
.finalized_head
.write()
.expect("CRITICAL: finalized_head poisioned.");
finalized_head.update(
new_beacon_block,
new_beacon_block_root,
new_beacon_state,
new_beacon_state_root,
);
}
pub fn finalized_head(&self) -> RwLockReadGuard<CheckPoint> {
self.finalized_head
.read()
.expect("CRITICAL: finalized_head poisioned.")
}
}