Rename BeaconStateTypes to EthSpec

This commit is contained in:
Paul Hauner
2019-05-10 14:47:09 +10:00
parent 75b310a078
commit ce8ebeccbc
60 changed files with 223 additions and 235 deletions

View File

@@ -10,7 +10,7 @@ use std::path::PathBuf;
use types::multiaddr::Protocol;
use types::multiaddr::ToMultiaddr;
use types::Multiaddr;
use types::{BeaconStateTypes, ChainSpec, LighthouseTestnetStateTypes};
use types::{ChainSpec, EthSpec, LighthouseTestnetEthSpec};
/// Stores the client configuration for this Lighthouse instance.
#[derive(Debug, Clone)]
@@ -35,7 +35,7 @@ impl Default for ClientConfig {
fs::create_dir_all(&data_dir)
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
let default_spec = LighthouseTestnetStateTypes::spec();
let default_spec = LighthouseTestnetEthSpec::spec();
let default_net_conf = NetworkConfig::new(default_spec.boot_nodes.clone());
Self {

View File

@@ -6,17 +6,17 @@ use beacon_chain::{
slot_clock::{SlotClock, SystemTimeSlotClock},
};
use fork_choice::ForkChoice;
use types::{BeaconStateTypes, FewValidatorsStateTypes, FoundationStateTypes};
use types::{EthSpec, FewValidatorsEthSpec, FoundationEthSpec};
pub trait ClientTypes {
type DB: ClientDB + 'static;
type SlotClock: SlotClock + 'static;
type ForkChoice: ForkChoice + 'static;
type BeaconStateTypes: BeaconStateTypes + 'static;
type EthSpec: EthSpec + 'static;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes>;
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec>;
}
pub struct StandardClientType;
@@ -24,12 +24,12 @@ pub struct StandardClientType;
impl ClientTypes for StandardClientType {
type DB = DiskDB;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = BitwiseLMDGhost<DiskDB, Self::BeaconStateTypes>;
type BeaconStateTypes = FoundationStateTypes;
type ForkChoice = BitwiseLMDGhost<DiskDB, Self::EthSpec>;
type EthSpec = FoundationEthSpec;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
initialise::initialise_beacon_chain(&config.spec, Some(&config.db_name))
}
}
@@ -39,12 +39,12 @@ pub struct TestingClientType;
impl ClientTypes for TestingClientType {
type DB = MemoryDB;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = BitwiseLMDGhost<MemoryDB, Self::BeaconStateTypes>;
type BeaconStateTypes = FewValidatorsStateTypes;
type ForkChoice = BitwiseLMDGhost<MemoryDB, Self::EthSpec>;
type EthSpec = FewValidatorsEthSpec;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::BeaconStateTypes> {
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
initialise::initialise_test_beacon_chain(&config.spec, None)
}
}

View File

@@ -20,7 +20,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::runtime::TaskExecutor;
use tokio::timer::Interval;
use types::BeaconStateTypes;
use types::EthSpec;
type ArcBeaconChain<D, S, F, B> = Arc<BeaconChain<D, S, F, B>>;
@@ -30,9 +30,9 @@ pub struct Client<T: ClientTypes> {
/// Configuration for the lighthouse client.
_config: ClientConfig,
/// The beacon chain for the running client.
_beacon_chain: ArcBeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::BeaconStateTypes>,
_beacon_chain: ArcBeaconChain<T::DB, T::SlotClock, T::ForkChoice, T::EthSpec>,
/// Reference to the network service.
pub network: Arc<NetworkService<T::BeaconStateTypes>>,
pub network: Arc<NetworkService<T::EthSpec>>,
/// Signal to terminate the RPC server.
pub rpc_exit_signal: Option<Signal>,
/// Signal to terminate the slot timer.
@@ -149,7 +149,7 @@ where
T: ClientDB,
U: SlotClock,
F: ForkChoice,
B: BeaconStateTypes,
B: EthSpec,
{
if let Some(genesis_height) = chain.slots_since_genesis() {
let result = chain.catchup_state();