Allow fork_choice and beacon_chain to compile

This commit is contained in:
Paul Hauner
2019-05-08 18:18:17 +10:00
parent 9fd8af8428
commit 51dc97ee42
8 changed files with 87 additions and 64 deletions

View File

@@ -7,17 +7,18 @@ use fork_choice::BitwiseLMDGhost;
use slot_clock::TestingSlotClock;
use std::sync::Arc;
use tree_hash::TreeHash;
use types::test_utils::TestingBeaconStateBuilder;
use types::*;
use types::{test_utils::TestingBeaconStateBuilder, BeaconStateTypes, FewValidatorsStateTypes};
type TestingBeaconChain = BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB>>;
type TestingBeaconChain<B> =
BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB, FewValidatorsStateTypes>, B>;
pub struct TestingBeaconChainBuilder {
state_builder: TestingBeaconStateBuilder,
pub struct TestingBeaconChainBuilder<B: BeaconStateTypes> {
state_builder: TestingBeaconStateBuilder<B>,
}
impl TestingBeaconChainBuilder {
pub fn build(self, spec: &ChainSpec) -> TestingBeaconChain {
impl<B: BeaconStateTypes> TestingBeaconChainBuilder<B> {
pub fn build(self, spec: &ChainSpec) -> TestingBeaconChain<B> {
let db = Arc::new(MemoryDB::open());
let block_store = Arc::new(BeaconBlockStore::new(db.clone()));
let state_store = Arc::new(BeaconStateStore::new(db.clone()));
@@ -43,8 +44,8 @@ impl TestingBeaconChainBuilder {
}
}
impl From<TestingBeaconStateBuilder> for TestingBeaconChainBuilder {
fn from(state_builder: TestingBeaconStateBuilder) -> TestingBeaconChainBuilder {
impl<B: BeaconStateTypes> From<TestingBeaconStateBuilder<B>> for TestingBeaconChainBuilder<B> {
fn from(state_builder: TestingBeaconStateBuilder<B>) -> TestingBeaconChainBuilder<B> {
TestingBeaconChainBuilder { state_builder }
}
}