hopr_chain_indexer/config.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/// Configuration for the chain indexer functionality
#[derive(Debug, Clone, Copy, smart_default::SmartDefault)]
pub struct IndexerConfig {
/// The block at which the indexer should start
///
/// It typically makes little sense to start indexing from the beginning
/// of the chain; all that is sufficient is to start indexing since the
/// relevant smart contracts were introduced into the chain.
///
/// This value makes sure that indexing is relevant and as minimal as possible.
///
/// Default is `0`.
pub start_block_number: u64,
/// Whether to use fast synchronization during indexing.
/// When enabled, it allows for quicker indexing of existing logs during node startup.
///
/// Default is `true`.
#[default(true)]
pub fast_sync: bool,
}
impl IndexerConfig {
/// Creates a new indexer configuration.
///
/// # Arguments
///
/// * `start_block_number` - The block number from which to start indexing
/// * `fast_sync` - Whether to enable fast synchronization during startup
///
/// # Returns
///
/// A new instance of `IndexerConfig`
pub fn new(start_block_number: u64, fast_sync: bool) -> Self {
Self {
start_block_number,
fast_sync,
}
}
}