Update fork choice find head fn

This commit is contained in:
Paul Hauner
2019-06-15 15:05:34 -04:00
parent 2ee71aa808
commit 7756a658a7
4 changed files with 71 additions and 27 deletions

View File

@@ -74,7 +74,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
genesis_block_root: Hash256,
/// A state-machine that is updated with information from the network and chooses a canonical
/// head block.
pub fork_choice: ForkChoice<T::LmdGhost, T::Store, T::EthSpec>,
pub fork_choice: ForkChoice<T>,
/// Stores metrics about this `BeaconChain`.
pub metrics: Metrics,
}
@@ -87,7 +87,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
mut genesis_state: BeaconState<T::EthSpec>,
genesis_block: BeaconBlock,
spec: ChainSpec,
fork_choice: ForkChoice<T::LmdGhost, T::Store, T::EthSpec>,
fork_choice: ForkChoice<T>,
) -> Result<Self, Error> {
let state_root = genesis_state.canonical_root();
store.put(&state_root, &genesis_state)?;
@@ -714,7 +714,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let timer = self.metrics.fork_choice_times.start_timer();
// Determine the root of the block that is the head of the chain.
let beacon_block_root = self.fork_choice.find_head()?;
let beacon_block_root = self.fork_choice.find_head(&self)?;
// End fork choice metrics timer.
timer.observe_duration();