use std::path::PathBuf;
use crate::constants::{
DEFAULT_BLOCK_CACHE_CAPACITY, DEFAULT_BLOCK_CACHE_SIZE, DEFAULT_HEADER_CACHE_CAPACITY,
DEFAULT_MAX_DECOMPRESSED_BLOCK_BYTES, DEFAULT_MAX_OPEN_FILES, DEFAULT_WRITE_BUFFER_SIZE,
ZSTD_COMPRESSION_LEVEL,
};
#[derive(Debug, Clone)]
pub struct BlockStoreConfig {
pub path: PathBuf,
pub block_cache_capacity: usize,
pub header_cache_capacity: usize,
pub cache_shards: usize,
pub warm_cache_on_open: bool,
pub warm_cache_depth: u64,
pub write_buffer_size: usize,
pub block_cache_size: usize,
pub max_open_files: i32,
pub enable_blob_db: bool,
pub compress_blocks: bool,
pub compression_level: i32,
pub use_compression_dict: bool,
pub max_decompressed_block_bytes: usize,
pub zstd_dictionary_override: Option<Vec<u8>>,
pub write_pipeline_batch_size: usize,
pub write_pipeline_flush_ms: u64,
pub write_pipeline_channel_capacity: usize,
pub sync_writes: bool,
pub readahead_size: usize,
pub canonical_height_cache_capacity: usize,
pub hash_to_height_cache_capacity: usize,
pub enable_compaction_pruning: bool,
pub min_retained_height: Option<u64>,
}
impl Default for BlockStoreConfig {
fn default() -> Self {
Self {
path: PathBuf::from("data/blockstore"),
block_cache_capacity: DEFAULT_BLOCK_CACHE_CAPACITY,
header_cache_capacity: DEFAULT_HEADER_CACHE_CAPACITY,
cache_shards: 16,
warm_cache_on_open: true,
warm_cache_depth: 64,
write_buffer_size: DEFAULT_WRITE_BUFFER_SIZE,
block_cache_size: DEFAULT_BLOCK_CACHE_SIZE,
max_open_files: DEFAULT_MAX_OPEN_FILES,
enable_blob_db: true,
compress_blocks: true,
compression_level: ZSTD_COMPRESSION_LEVEL,
use_compression_dict: true,
max_decompressed_block_bytes: DEFAULT_MAX_DECOMPRESSED_BLOCK_BYTES,
zstd_dictionary_override: None,
write_pipeline_batch_size: 64,
write_pipeline_flush_ms: 100,
write_pipeline_channel_capacity: 256,
sync_writes: false,
readahead_size: 2_097_152,
canonical_height_cache_capacity: 10_000,
hash_to_height_cache_capacity: 10_000,
enable_compaction_pruning: false,
min_retained_height: None,
}
}
}