2026-01-30 12:51:18 +02:00
|
|
|
use std::{
|
|
|
|
|
fs::File,
|
|
|
|
|
io::BufReader,
|
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
|
};
|
2026-01-23 10:39:34 +02:00
|
|
|
|
2026-01-27 09:46:31 +02:00
|
|
|
use anyhow::{Context, Result};
|
|
|
|
|
use bedrock_client::BackoffConfig;
|
2026-01-30 12:51:18 +02:00
|
|
|
use common::{
|
|
|
|
|
block::{AccountInitialData, CommitmentsInitialData},
|
|
|
|
|
sequencer_client::BasicAuth,
|
|
|
|
|
};
|
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-27 09:46:31 +02:00
|
|
|
use url::Url;
|
2026-01-12 15:51:24 +02:00
|
|
|
|
2026-01-22 14:44:48 +02:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
2026-01-29 22:34:27 +03:00
|
|
|
pub struct BedrockClientConfig {
|
2026-01-27 09:46:31 +02:00
|
|
|
pub addr: Url,
|
|
|
|
|
pub auth: Option<BasicAuth>,
|
2026-01-22 14:44:48 +02:00
|
|
|
}
|
|
|
|
|
|
2026-01-13 15:11:51 +02:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
2026-01-12 15:51:24 +02:00
|
|
|
pub struct IndexerConfig {
|
2026-01-30 12:51:18 +02:00
|
|
|
/// Home dir of sequencer storage
|
|
|
|
|
pub home: PathBuf,
|
|
|
|
|
/// List of initial accounts data
|
|
|
|
|
pub initial_accounts: Vec<AccountInitialData>,
|
|
|
|
|
/// List of initial commitments
|
|
|
|
|
pub initial_commitments: Vec<CommitmentsInitialData>,
|
2026-01-21 14:50:29 +02:00
|
|
|
pub resubscribe_interval_millis: u64,
|
2026-01-29 22:34:27 +03:00
|
|
|
/// For individual RPC requests we use Fibonacci backoff retry strategy.
|
2026-01-27 09:46:31 +02:00
|
|
|
pub backoff: BackoffConfig,
|
2026-01-29 22:34:27 +03:00
|
|
|
pub bedrock_client_config: BedrockClientConfig,
|
2026-01-22 14:44:48 +02:00
|
|
|
pub channel_id: ChannelId,
|
2026-01-12 15:51:24 +02:00
|
|
|
}
|
2026-01-23 10:39:34 +02:00
|
|
|
|
|
|
|
|
impl IndexerConfig {
|
2026-01-29 23:03:00 +03:00
|
|
|
pub fn from_path(config_path: &Path) -> Result<IndexerConfig> {
|
|
|
|
|
let file = File::open(config_path)
|
|
|
|
|
.with_context(|| format!("Failed to open indexer config at {config_path:?}"))?;
|
2026-01-23 10:39:34 +02:00
|
|
|
let reader = BufReader::new(file);
|
|
|
|
|
|
2026-01-27 09:46:31 +02:00
|
|
|
serde_json::from_reader(reader)
|
2026-01-29 23:03:00 +03:00
|
|
|
.with_context(|| format!("Failed to parse indexer config at {config_path:?}"))
|
2026-01-23 10:39:34 +02:00
|
|
|
}
|
|
|
|
|
}
|