Add chain.justified_head

This commit is contained in:
Paul Hauner 2019-01-28 13:00:08 +11:00
parent b516fd472e
commit d1ac7c037d
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 16 additions and 0 deletions

View File

@ -44,4 +44,12 @@ where
let state = self.state(present_slot).ok()?;
state.get_beacon_proposer_index(slot, &self.spec)
}
pub fn justified_slot(&self) -> u64 {
self.justified_head
.read()
.expect("Justified head poisoned")
.beacon_block
.slot
}
}

View File

@ -74,6 +74,7 @@ pub struct BeaconChain<T: ClientDB + Sized, U: SlotClock> {
pub block_graph: BlockGraph,
canonical_head: RwLock<CheckPoint>,
finalized_head: RwLock<CheckPoint>,
justified_head: RwLock<CheckPoint>,
pub latest_attestation_targets: RwLock<AttestationTargets>,
pub spec: ChainSpec,
}
@ -110,6 +111,12 @@ where
genesis_state.clone(),
state_root.clone(),
));
let justified_head = RwLock::new(CheckPoint::new(
genesis_block.clone(),
block_root.clone(),
genesis_state.clone(),
state_root.clone(),
));
let canonical_head = RwLock::new(CheckPoint::new(
genesis_block.clone(),
block_root.clone(),
@ -124,6 +131,7 @@ where
state_store,
slot_clock,
block_graph,
justified_head,
finalized_head,
canonical_head,
latest_attestation_targets,