mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Modularize beacon node backend (#4718)
#4669 Modularize the beacon node backend to make it easier to add new database implementations
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
use crate::hdiff::HierarchyConfig;
|
||||
use crate::superstruct;
|
||||
use crate::{AnchorInfo, DBColumn, Error, Split, StoreItem};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz::{Decode, Encode};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::io::Write;
|
||||
use std::num::NonZeroUsize;
|
||||
use superstruct::superstruct;
|
||||
use strum::{Display, EnumString, EnumVariantNames};
|
||||
use types::non_zero_usize::new_non_zero_usize;
|
||||
use types::EthSpec;
|
||||
use zstd::Encoder;
|
||||
|
||||
// Only used in tests. Mainnet sets a higher default on the CLI.
|
||||
#[cfg(all(feature = "redb", not(feature = "leveldb")))]
|
||||
pub const DEFAULT_BACKEND: DatabaseBackend = DatabaseBackend::Redb;
|
||||
#[cfg(feature = "leveldb")]
|
||||
pub const DEFAULT_BACKEND: DatabaseBackend = DatabaseBackend::LevelDb;
|
||||
|
||||
pub const PREV_DEFAULT_SLOTS_PER_RESTORE_POINT: u64 = 2048;
|
||||
pub const DEFAULT_SLOTS_PER_RESTORE_POINT: u64 = 8192;
|
||||
pub const DEFAULT_EPOCHS_PER_STATE_DIFF: u64 = 8;
|
||||
pub const DEFAULT_BLOCK_CACHE_SIZE: NonZeroUsize = new_non_zero_usize(64);
|
||||
pub const DEFAULT_STATE_CACHE_SIZE: NonZeroUsize = new_non_zero_usize(128);
|
||||
@@ -40,6 +47,8 @@ pub struct StoreConfig {
|
||||
pub compact_on_prune: bool,
|
||||
/// Whether to prune payloads on initialization and finalization.
|
||||
pub prune_payloads: bool,
|
||||
/// Database backend to use.
|
||||
pub backend: DatabaseBackend,
|
||||
/// State diff hierarchy.
|
||||
pub hierarchy_config: HierarchyConfig,
|
||||
/// Whether to prune blobs older than the blob data availability boundary.
|
||||
@@ -104,6 +113,7 @@ impl Default for StoreConfig {
|
||||
compact_on_init: false,
|
||||
compact_on_prune: true,
|
||||
prune_payloads: true,
|
||||
backend: DEFAULT_BACKEND,
|
||||
hierarchy_config: HierarchyConfig::default(),
|
||||
prune_blobs: true,
|
||||
epochs_per_blob_prune: DEFAULT_EPOCHS_PER_BLOB_PRUNE,
|
||||
@@ -340,3 +350,14 @@ mod test {
|
||||
assert_eq!(config_out, config);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Display, EnumString, EnumVariantNames,
|
||||
)]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
pub enum DatabaseBackend {
|
||||
#[cfg(feature = "leveldb")]
|
||||
LevelDb,
|
||||
#[cfg(feature = "redb")]
|
||||
Redb,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user