Remove readers from fork choice crate.

This commit is contained in:
Paul Hauner
2019-03-17 17:59:29 +11:00
parent 8b08e9dd2e
commit d94540c85c
3 changed files with 31 additions and 32 deletions

View File

@@ -9,8 +9,7 @@ use log::{debug, trace};
use std::collections::HashMap;
use std::sync::Arc;
use types::{
readers::BeaconBlockReader, validator_registry::get_active_validator_indices, BeaconBlock,
ChainSpec, Hash256, Slot,
validator_registry::get_active_validator_indices, BeaconBlock, ChainSpec, Hash256, Slot,
};
//TODO: Pruning and syncing
@@ -95,7 +94,7 @@ where
.block_store
.get_deserialized(&block_root)?
.ok_or_else(|| ForkChoiceError::MissingBeaconBlock(*block_root))?
.slot();
.slot;
for (vote_hash, votes) in latest_votes.iter() {
let (root_at_slot, _) = self
@@ -122,7 +121,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
// add the new block to the children of parent
(*self
.children
.entry(block.parent_root)
.entry(block.previous_block_root)
.or_insert_with(|| vec![]))
.push(block_hash.clone());
@@ -155,7 +154,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
.block_store
.get_deserialized(&target_block_root)?
.ok_or_else(|| ForkChoiceError::MissingBeaconBlock(*target_block_root))?
.slot()
.slot
.height(spec.genesis_slot);
// get the height of the past target block
@@ -163,7 +162,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
.block_store
.get_deserialized(&attestation_target)?
.ok_or_else(|| ForkChoiceError::MissingBeaconBlock(*attestation_target))?
.slot()
.slot
.height(spec.genesis_slot);
// update the attestation only if the new target is higher
if past_block_height < block_height {
@@ -186,9 +185,9 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
.get_deserialized(&justified_block_start)?
.ok_or_else(|| ForkChoiceError::MissingBeaconBlock(*justified_block_start))?;
let start_state_root = start.state_root();
let start_state_root = start.state_root;
let latest_votes = self.get_latest_votes(&start_state_root, start.slot(), spec)?;
let latest_votes = self.get_latest_votes(&start_state_root, start.slot, spec)?;
let mut head_hash = *justified_block_start;