mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 04:42:34 +00:00
Update beacon_chain as per test bugs
This commit is contained in:
34
beacon_node/beacon_chain/src/finalized_head.rs
Normal file
34
beacon_node/beacon_chain/src/finalized_head.rs
Normal 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.")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user