Integrate ForkChoice into beacon_node.

This commit is contained in:
Age Manning
2019-02-13 16:29:37 +11:00
parent c4c1e5647e
commit 4370035448
9 changed files with 55 additions and 39 deletions

View File

@@ -30,7 +30,7 @@ use types::{BeaconBlock, Hash256};
/// Defines the interface for Fork Choices. Each Fork choice will define their own data structures
/// which can be built in block processing through the `add_block` and `add_attestation` functions.
/// The main fork choice algorithm is specified in `find_head
pub trait ForkChoice {
pub trait ForkChoice: Send + Sync {
/// Called when a block has been added. Allows generic block-level data structures to be
/// built for a given fork-choice.
fn add_block(

View File

@@ -62,15 +62,18 @@ impl<T> OptimisedLMDGhost<T>
where
T: ClientDB + Sized,
{
pub fn new(block_store: BeaconBlockStore<T>, state_store: BeaconStateStore<T>) -> Self {
pub fn new(
block_store: Arc<BeaconBlockStore<T>>,
state_store: Arc<BeaconStateStore<T>>,
) -> Self {
OptimisedLMDGhost {
cache: HashMap::new(),
ancestors: vec![HashMap::new(); 16],
latest_attestation_targets: HashMap::new(),
children: HashMap::new(),
max_known_height: 0,
block_store: Arc::new(block_store),
state_store: Arc::new(state_store),
block_store,
state_store,
}
}