2023-11-15 17:32:22 -08:00
|
|
|
//! Configuration for blockchain scanning tasks.
|
|
|
|
|
|
|
|
use indexmap::IndexMap;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2023-11-30 04:59:15 -08:00
|
|
|
use zebra_state::Config as DbConfig;
|
|
|
|
|
2023-11-15 17:32:22 -08:00
|
|
|
use crate::storage::SaplingScanningKey;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
|
|
|
#[serde(deny_unknown_fields, default)]
|
|
|
|
/// Configuration for scanning.
|
|
|
|
pub struct Config {
|
|
|
|
/// The sapling keys to scan for and the birthday height of each of them.
|
2023-11-30 04:59:15 -08:00
|
|
|
//
|
|
|
|
// TODO: allow keys without birthdays
|
2023-11-15 17:32:22 -08:00
|
|
|
pub sapling_keys_to_scan: IndexMap<SaplingScanningKey, u32>,
|
2023-11-30 04:59:15 -08:00
|
|
|
|
|
|
|
/// The scanner results database config.
|
|
|
|
//
|
|
|
|
// TODO: Remove fields that are only used by the state to create a common database config.
|
|
|
|
#[serde(flatten)]
|
|
|
|
db_config: DbConfig,
|
2023-11-15 17:32:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Config {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
sapling_keys_to_scan: IndexMap::new(),
|
2023-11-30 04:59:15 -08:00
|
|
|
db_config: DbConfig::default(),
|
2023-11-15 17:32:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-30 04:59:15 -08:00
|
|
|
|
|
|
|
impl Config {
|
|
|
|
/// Returns a config for a temporary database that is deleted when it is dropped.
|
|
|
|
pub fn ephemeral() -> Self {
|
|
|
|
Self {
|
|
|
|
db_config: DbConfig::ephemeral(),
|
|
|
|
..Self::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the database-specific config.
|
|
|
|
pub fn db_config(&self) -> &DbConfig {
|
|
|
|
&self.db_config
|
|
|
|
}
|
|
|
|
}
|