Module cuprate_blockchain::config
source · Expand description
Database configuration.
This module contains the main Configuration struct
for the database Environment,
and blockchain-specific configuration.
It also contains types related to configuration settings.
The main constructor is the ConfigBuilder.
These configurations are processed at runtime, meaning
the Env can/will dynamically adjust its behavior based
on these values.
§Example
use cuprate_blockchain::{
cuprate_database::{Env, config::SyncMode},
config::{ConfigBuilder, ReaderThreads},
};
let tmp_dir = tempfile::tempdir()?;
let db_dir = tmp_dir.path().to_owned();
let config = ConfigBuilder::new()
// Use a custom database directory.
.db_directory(db_dir.into())
// Use as many reader threads as possible (when using `service`).
.reader_threads(ReaderThreads::OnePerThread)
// Use the fastest sync mode.
.sync_mode(SyncMode::Fast)
// Build into `Config`
.build();
// Start a database `service` using this configuration.
let (reader_handle, _) = cuprate_blockchain::service::init(config.clone())?;
// It's using the config we provided.
assert_eq!(reader_handle.env().config(), &config.db_config);Structs§
cuprate_blockchainconfiguration.- Builder for
Config.
Enums§
- Amount of database reader threads to spawn when using
service.