lssa/indexer_core/src/config.rs

33 lines
957 B
Rust
Raw Normal View History

2026-01-23 10:39:34 +02:00
use std::{fs::File, io::BufReader, path::Path};
use anyhow::Result;
2026-01-27 08:13:53 +02:00
use logos_blockchain_core::mantle::ops::channel::ChannelId;
2026-01-13 15:11:51 +02:00
use serde::{Deserialize, Serialize};
2026-01-12 15:51:24 +02:00
2026-01-22 14:44:48 +02:00
#[derive(Debug, Clone, Serialize, Deserialize)]
/// ToDo: Expand if necessary
pub struct ClientConfig {
pub addr: String,
pub auth: Option<(String, Option<String>)>,
}
2026-01-13 15:11:51 +02:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2026-01-21 14:50:29 +02:00
/// Note: For individual RPC requests we use Fibonacci backoff retry strategy
2026-01-12 15:51:24 +02:00
pub struct IndexerConfig {
2026-01-21 14:50:29 +02:00
pub resubscribe_interval_millis: u64,
pub start_delay_millis: u64,
pub max_retries: usize,
2026-01-22 14:44:48 +02:00
pub bedrock_client_config: ClientConfig,
pub sequencer_client_config: ClientConfig,
pub channel_id: ChannelId,
2026-01-12 15:51:24 +02:00
}
2026-01-23 10:39:34 +02:00
impl IndexerConfig {
pub fn from_path(config_home: &Path) -> Result<IndexerConfig> {
let file = File::open(config_home)?;
let reader = BufReader::new(file);
Ok(serde_json::from_reader(reader)?)
}
}