mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Rename db crate to store
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::checkpoint::CheckPoint;
|
||||
use crate::errors::{BeaconChainError as Error, BlockProductionError};
|
||||
use db::{Error as DBError, Store};
|
||||
use fork_choice::{ForkChoice, ForkChoiceError};
|
||||
use log::{debug, trace};
|
||||
use operation_pool::DepositInsertStatus;
|
||||
@@ -16,6 +15,7 @@ use state_processing::{
|
||||
per_slot_processing, BlockProcessingError, SlotProcessingError,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use store::{Error as DBError, Store};
|
||||
use types::*;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
||||
@@ -20,7 +20,7 @@ pub enum BeaconChainError {
|
||||
UnableToReadSlot,
|
||||
BeaconStateError(BeaconStateError),
|
||||
DBInconsistent(String),
|
||||
DBError(db::Error),
|
||||
DBError(store::Error),
|
||||
ForkChoiceError(ForkChoiceError),
|
||||
MissingBeaconBlock(Hash256),
|
||||
MissingBeaconState(Hash256),
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// testnet. These are examples. Also. there is code duplication which can/should be cleaned up.
|
||||
|
||||
use crate::BeaconChain;
|
||||
use db::{DiskDB, MemoryDB};
|
||||
use fork_choice::BitwiseLMDGhost;
|
||||
use slot_clock::SystemTimeSlotClock;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use store::{DiskStore, MemoryStore};
|
||||
use tree_hash::TreeHash;
|
||||
use types::test_utils::TestingBeaconStateBuilder;
|
||||
use types::{BeaconBlock, ChainSpec, FewValidatorsEthSpec, FoundationEthSpec, Hash256};
|
||||
@@ -19,14 +19,14 @@ pub fn initialise_beacon_chain(
|
||||
db_name: Option<&PathBuf>,
|
||||
) -> Arc<
|
||||
BeaconChain<
|
||||
DiskDB,
|
||||
DiskStore,
|
||||
SystemTimeSlotClock,
|
||||
BitwiseLMDGhost<DiskDB, FoundationEthSpec>,
|
||||
BitwiseLMDGhost<DiskStore, FoundationEthSpec>,
|
||||
FoundationEthSpec,
|
||||
>,
|
||||
> {
|
||||
let path = db_name.expect("db_name cannot be None.");
|
||||
let store = DiskDB::open(path).expect("Unable to open DB.");
|
||||
let store = DiskStore::open(path).expect("Unable to open DB.");
|
||||
let store = Arc::new(store);
|
||||
|
||||
let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, &spec);
|
||||
@@ -66,13 +66,13 @@ pub fn initialise_test_beacon_chain_with_memory_db(
|
||||
_db_name: Option<&PathBuf>,
|
||||
) -> Arc<
|
||||
BeaconChain<
|
||||
MemoryDB,
|
||||
MemoryStore,
|
||||
SystemTimeSlotClock,
|
||||
BitwiseLMDGhost<MemoryDB, FewValidatorsEthSpec>,
|
||||
BitwiseLMDGhost<MemoryStore, FewValidatorsEthSpec>,
|
||||
FewValidatorsEthSpec,
|
||||
>,
|
||||
> {
|
||||
let store = Arc::new(MemoryDB::open());
|
||||
let store = Arc::new(MemoryStore::open());
|
||||
|
||||
let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, spec);
|
||||
let (genesis_state, _keypairs) = state_builder.build();
|
||||
@@ -111,14 +111,14 @@ pub fn initialise_test_beacon_chain_with_disk_db(
|
||||
db_name: Option<&PathBuf>,
|
||||
) -> Arc<
|
||||
BeaconChain<
|
||||
DiskDB,
|
||||
DiskStore,
|
||||
SystemTimeSlotClock,
|
||||
BitwiseLMDGhost<DiskDB, FewValidatorsEthSpec>,
|
||||
BitwiseLMDGhost<DiskStore, FewValidatorsEthSpec>,
|
||||
FewValidatorsEthSpec,
|
||||
>,
|
||||
> {
|
||||
let path = db_name.expect("db_name cannot be None.");
|
||||
let store = DiskDB::open(path).expect("Unable to open DB.");
|
||||
let store = DiskStore::open(path).expect("Unable to open DB.");
|
||||
let store = Arc::new(store);
|
||||
|
||||
let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, spec);
|
||||
|
||||
@@ -7,7 +7,6 @@ pub mod test_utils;
|
||||
pub use self::beacon_chain::{BeaconChain, BlockProcessingOutcome, InvalidBlock, ValidBlock};
|
||||
pub use self::checkpoint::CheckPoint;
|
||||
pub use self::errors::{BeaconChainError, BlockProductionError};
|
||||
pub use db;
|
||||
pub use fork_choice;
|
||||
pub use parking_lot;
|
||||
pub use slot_clock;
|
||||
@@ -15,4 +14,5 @@ pub use state_processing::per_block_processing::errors::{
|
||||
AttestationValidationError, AttesterSlashingValidationError, DepositValidationError,
|
||||
ExitValidationError, ProposerSlashingValidationError, TransferValidationError,
|
||||
};
|
||||
pub use store;
|
||||
pub use types;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
pub use crate::{BeaconChain, BeaconChainError, CheckPoint};
|
||||
use db::MemoryDB;
|
||||
use fork_choice::BitwiseLMDGhost;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::sync::Arc;
|
||||
use store::MemoryStore;
|
||||
use tree_hash::TreeHash;
|
||||
use types::*;
|
||||
use types::{test_utils::TestingBeaconStateBuilder, EthSpec, FewValidatorsEthSpec};
|
||||
|
||||
type TestingBeaconChain<E> =
|
||||
BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB, FewValidatorsEthSpec>, E>;
|
||||
type TestingBeaconChain<E> = BeaconChain<
|
||||
MemoryStore,
|
||||
TestingSlotClock,
|
||||
BitwiseLMDGhost<MemoryStore, FewValidatorsEthSpec>,
|
||||
E,
|
||||
>;
|
||||
|
||||
pub struct TestingBeaconChainBuilder<E: EthSpec> {
|
||||
state_builder: TestingBeaconStateBuilder<E>,
|
||||
@@ -16,7 +20,7 @@ pub struct TestingBeaconChainBuilder<E: EthSpec> {
|
||||
|
||||
impl<E: EthSpec> TestingBeaconChainBuilder<E> {
|
||||
pub fn build(self, spec: &ChainSpec) -> TestingBeaconChain<E> {
|
||||
let store = Arc::new(MemoryDB::open());
|
||||
let store = Arc::new(MemoryStore::open());
|
||||
let slot_clock = TestingSlotClock::new(spec.genesis_slot.as_u64());
|
||||
let fork_choice = BitwiseLMDGhost::new(store.clone());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user