mod secondary;
mod shared;
use anyhow::Context;
use arti_client::{TorClient, TorClientConfig};
use dotenv::dotenv;
use env_logger::{Builder, Target};
use erpc_scanner::relay::NetDirProvider;
use log::info;
use secondary::{config::SecondaryWorkerConfig, worker::SecondaryWorker};
#[tokio::main]
#[deny(clippy::await_holding_lock)]
#[deny(clippy::print_stderr)]
#[deny(clippy::print_stdout)]
async fn main() -> anyhow::Result<()> {
dotenv().context(".env file not found")?;
let mut builder = Builder::from_default_env();
builder.target(Target::Stdout).init();
info!("Loading the configs from .env file");
let secondary_worker_config = SecondaryWorkerConfig::from_env()?;
info!("Current configs set to {secondary_worker_config:#?}");
info!("Spawning a bootstrapped arti_client::TorClient");
let tor_client_config = TorClientConfig::default();
let tor_client = TorClient::create_bootstrapped(tor_client_config).await?;
info!("Spawned a bootstrapped arti_client::TorClient");
let circmgr = tor_client.circmgr().clone();
let dirmgr = tor_client.dirmgr().clone();
let netdir_provider = NetDirProvider::from_dirmgr(dirmgr).await?;
let mut secondary_worker = SecondaryWorker::new(secondary_worker_config, netdir_provider, circmgr);
secondary_worker.start().await?;
Ok(())
}