mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
More project-wide fixes for new DB
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use clap::ArgMatches;
|
||||
use db::DBType;
|
||||
use fork_choice::ForkChoiceAlgorithm;
|
||||
use network::NetworkConfig;
|
||||
use slog::error;
|
||||
@@ -12,6 +11,12 @@ use types::multiaddr::ToMultiaddr;
|
||||
use types::Multiaddr;
|
||||
use types::{ChainSpec, EthSpec, LighthouseTestnetEthSpec};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DBType {
|
||||
Memory,
|
||||
Disk,
|
||||
}
|
||||
|
||||
/// Stores the client configuration for this Lighthouse instance.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ClientConfig {
|
||||
@@ -132,7 +137,7 @@ impl ClientConfig {
|
||||
}
|
||||
|
||||
match args.value_of("db") {
|
||||
Some("rocks") => config.db_type = DBType::RocksDB,
|
||||
Some("disk") => config.db_type = DBType::Disk,
|
||||
Some("memory") => config.db_type = DBType::Memory,
|
||||
_ => unreachable!(), // clap prevents this.
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{ArcBeaconChain, ClientConfig};
|
||||
use beacon_chain::{
|
||||
db::{ClientDB, DiskDB, MemoryDB},
|
||||
db::{DiskDB, MemoryDB, Store},
|
||||
fork_choice::BitwiseLMDGhost,
|
||||
initialise,
|
||||
slot_clock::{SlotClock, SystemTimeSlotClock},
|
||||
@@ -9,7 +9,7 @@ use fork_choice::ForkChoice;
|
||||
use types::{EthSpec, FewValidatorsEthSpec, FoundationEthSpec};
|
||||
|
||||
pub trait ClientTypes {
|
||||
type DB: ClientDB + 'static;
|
||||
type DB: Store + 'static;
|
||||
type SlotClock: SlotClock + 'static;
|
||||
type ForkChoice: ForkChoice + 'static;
|
||||
type EthSpec: EthSpec + 'static;
|
||||
@@ -24,7 +24,7 @@ pub struct StandardClientType;
|
||||
impl ClientTypes for StandardClientType {
|
||||
type DB = DiskDB;
|
||||
type SlotClock = SystemTimeSlotClock;
|
||||
type ForkChoice = BitwiseLMDGhost<DiskDB, Self::EthSpec>;
|
||||
type ForkChoice = BitwiseLMDGhost<Self::DB, Self::EthSpec>;
|
||||
type EthSpec = FoundationEthSpec;
|
||||
|
||||
fn initialise_beacon_chain(
|
||||
@@ -39,12 +39,27 @@ pub struct MemoryDBTestingClientType;
|
||||
impl ClientTypes for MemoryDBTestingClientType {
|
||||
type DB = MemoryDB;
|
||||
type SlotClock = SystemTimeSlotClock;
|
||||
type ForkChoice = BitwiseLMDGhost<MemoryDB, Self::EthSpec>;
|
||||
type ForkChoice = BitwiseLMDGhost<Self::DB, Self::EthSpec>;
|
||||
type EthSpec = FewValidatorsEthSpec;
|
||||
|
||||
fn initialise_beacon_chain(
|
||||
config: &ClientConfig,
|
||||
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
|
||||
initialise::initialise_test_beacon_chain(&config.spec, None)
|
||||
initialise::initialise_test_beacon_chain_with_memory_db(&config.spec, None)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DiskDBTestingClientType;
|
||||
|
||||
impl ClientTypes for DiskDBTestingClientType {
|
||||
type DB = DiskDB;
|
||||
type SlotClock = SystemTimeSlotClock;
|
||||
type ForkChoice = BitwiseLMDGhost<Self::DB, Self::EthSpec>;
|
||||
type EthSpec = FewValidatorsEthSpec;
|
||||
|
||||
fn initialise_beacon_chain(
|
||||
config: &ClientConfig,
|
||||
) -> ArcBeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice, Self::EthSpec> {
|
||||
initialise::initialise_test_beacon_chain_with_disk_db(&config.spec, Some(&config.db_name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ pub mod error;
|
||||
pub mod notifier;
|
||||
|
||||
use beacon_chain::BeaconChain;
|
||||
pub use client_config::ClientConfig;
|
||||
pub use client_config::{ClientConfig, DBType};
|
||||
pub use client_types::ClientTypes;
|
||||
use db::ClientDB;
|
||||
use db::Store;
|
||||
use exit_future::Signal;
|
||||
use fork_choice::ForkChoice;
|
||||
use futures::{future::Future, Stream};
|
||||
@@ -146,7 +146,7 @@ impl<TClientType: ClientTypes> Client<TClientType> {
|
||||
|
||||
fn do_state_catchup<T, U, F, E>(chain: &Arc<BeaconChain<T, U, F, E>>, log: &slog::Logger)
|
||||
where
|
||||
T: ClientDB,
|
||||
T: Store,
|
||||
U: SlotClock,
|
||||
F: ForkChoice,
|
||||
E: EthSpec,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use beacon_chain::BeaconChain as RawBeaconChain;
|
||||
use beacon_chain::{
|
||||
db::ClientDB,
|
||||
db::Store,
|
||||
fork_choice::ForkChoice,
|
||||
parking_lot::RwLockReadGuard,
|
||||
slot_clock::SlotClock,
|
||||
@@ -66,7 +66,7 @@ pub trait BeaconChain<E: EthSpec>: Send + Sync {
|
||||
|
||||
impl<T, U, F, E> BeaconChain<E> for RawBeaconChain<T, U, F, E>
|
||||
where
|
||||
T: ClientDB + Sized,
|
||||
T: Store,
|
||||
U: SlotClock,
|
||||
F: ForkChoice,
|
||||
E: EthSpec,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use beacon_chain::BeaconChain as RawBeaconChain;
|
||||
use beacon_chain::{
|
||||
db::ClientDB,
|
||||
db::Store,
|
||||
fork_choice::ForkChoice,
|
||||
parking_lot::{RwLockReadGuard, RwLockWriteGuard},
|
||||
slot_clock::SlotClock,
|
||||
@@ -36,7 +36,7 @@ pub trait BeaconChain<E: EthSpec>: Send + Sync {
|
||||
|
||||
impl<T, U, F, E> BeaconChain<E> for RawBeaconChain<T, U, F, E>
|
||||
where
|
||||
T: ClientDB + Sized,
|
||||
T: Store,
|
||||
U: SlotClock,
|
||||
F: ForkChoice,
|
||||
E: EthSpec,
|
||||
|
||||
@@ -74,7 +74,7 @@ fn main() {
|
||||
.value_name("DB")
|
||||
.help("Type of database to use.")
|
||||
.takes_value(true)
|
||||
.possible_values(&["rocks", "memory"])
|
||||
.possible_values(&["disk", "memory"])
|
||||
.default_value("memory"),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use client::client_types::{DiskDBTestingClientType, MemoryDBTestingClientType};
|
||||
use client::error;
|
||||
use client::{error, DBType};
|
||||
use client::{notifier, Client, ClientConfig, ClientTypes};
|
||||
use db::DBType;
|
||||
use futures::sync::oneshot;
|
||||
use futures::Future;
|
||||
use slog::info;
|
||||
@@ -26,7 +25,7 @@ pub fn run_beacon_node(config: ClientConfig, log: &slog::Logger) -> error::Resul
|
||||
let executor = runtime.executor();
|
||||
|
||||
match config.db_type {
|
||||
DBType::RocksDB => {
|
||||
DBType::Disk => {
|
||||
info!(
|
||||
log,
|
||||
"BeaconNode starting";
|
||||
|
||||
Reference in New Issue
Block a user