cuprate_blockchain

Module 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 (_, _, env) = cuprate_blockchain::service::init(config.clone())?;
// It's using the config we provided.
assert_eq!(env.config(), &config.db_config);

Structs§

Enums§