Modify runtime to allow memory or disk db

DiskDB is not working yet, but we'll get there!
This commit is contained in:
Paul Hauner
2019-03-31 18:57:48 +11:00
parent 9a0ebac687
commit 08b1808745
6 changed files with 107 additions and 13 deletions

View File

@@ -119,6 +119,12 @@ impl ClientConfig {
}
}
match args.value_of("db") {
Some("rocks") => config.db_type = DBType::RocksDB,
Some("memory") => config.db_type = DBType::Memory,
_ => unreachable!(), // clap prevents this.
};
Ok(config)
}
}

View File

@@ -34,9 +34,9 @@ impl ClientTypes for StandardClientType {
}
}
pub struct TestingClientType;
pub struct MemoryDBTestingClientType;
impl ClientTypes for TestingClientType {
impl ClientTypes for MemoryDBTestingClientType {
type DB = MemoryDB;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = BitwiseLMDGhost<MemoryDB>;
@@ -44,6 +44,20 @@ impl ClientTypes for TestingClientType {
fn initialise_beacon_chain(
config: &ClientConfig,
) -> Arc<BeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice>> {
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<DiskDB>;
fn initialise_beacon_chain(
config: &ClientConfig,
) -> Arc<BeaconChain<Self::DB, Self::SlotClock, Self::ForkChoice>> {
initialise::initialise_test_beacon_chain_with_disk_db(&config.spec, Some(&config.db_name))
}
}