pub struct IndexerConfig {
pub start_block_number: u64,
pub fast_sync: bool,
pub enable_logs_snapshot: bool,
pub logs_snapshot_url: Option<String>,
pub data_directory: String,
}
Expand description
Configuration for the chain indexer functionality
Fields§
§start_block_number: u64
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
.
fast_sync: bool
Whether to use fast synchronization during indexing. When enabled, it allows for quicker indexing of existing logs during node startup.
Default is true
.
enable_logs_snapshot: bool
Whether to perform logs snapshot download on startup. When enabled, it allows for quicker indexing from scratch.
Default is false
.
logs_snapshot_url: Option<String>
URL to download logs snapshot from. This should point to a publicly accessible tar.xz file containing the SQLite logs database files.
Default is None
data_directory: String
Path to the data directory where databases are stored. This is used for snapshot installation and database state checking.
Default is empty string (must be set by application).
Implementations§
Source§impl IndexerConfig
impl IndexerConfig
Sourcepub fn new(
start_block_number: u64,
fast_sync: bool,
enable_logs_snapshot: bool,
logs_snapshot_url: Option<String>,
data_directory: String,
) -> Self
pub fn new( start_block_number: u64, fast_sync: bool, enable_logs_snapshot: bool, logs_snapshot_url: Option<String>, data_directory: String, ) -> Self
Creates a new indexer configuration.
§Arguments
start_block_number
- The block number from which to start indexingfast_sync
- Whether to enable fast synchronization during startupenable_logs_snapshot
- Whether to enable logs snapshot downloadlogs_snapshot_url
- URL to download logs snapshot fromdata_directory
- Path to the data directory where databases are stored
§Returns
A new instance of IndexerConfig
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validates the configuration and returns any validation errors.
Performs comprehensive validation of configuration parameters including:
- URL format and protocol validation (HTTP/HTTPS/file:// supported)
- File extension validation (.tar.xz required)
- Data directory path validation
- Dependency validation (data directory required when snapshots enabled)
§Returns
Ok(())
if all validation passesErr(String)
with a descriptive error message if validation fails
§Example
use hopr_chain_indexer::IndexerConfig;
let config = IndexerConfig::new(
100,
true,
true,
Some("https://example.com/snapshot.tar.xz".to_string()),
"/tmp/hopr_data".to_string(),
);
assert!(config.validate().is_ok());
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Convenience method to check if the configuration is valid.
This is a simple wrapper around validate()
that returns a boolean
instead of a Result
, making it easier to use in conditional expressions.
§Returns
true
if all validation passes, false
otherwise
§Example
use hopr_chain_indexer::IndexerConfig;
let config = IndexerConfig::default();
if !config.is_valid() {
// Handle invalid configuration
}
Trait Implementations§
Source§impl Clone for IndexerConfig
impl Clone for IndexerConfig
Source§fn clone(&self) -> IndexerConfig
fn clone(&self) -> IndexerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for IndexerConfig
impl Debug for IndexerConfig
Auto Trait Implementations§
impl Freeze for IndexerConfig
impl RefUnwindSafe for IndexerConfig
impl Send for IndexerConfig
impl Sync for IndexerConfig
impl Unpin for IndexerConfig
impl UnwindSafe for IndexerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more