Aditya Arora 3 meses atrás
pai
commit
26cb6785d9
2 arquivos alterados com 8 adições e 8 exclusões
  1. 4 4
      apps/fortuna/src/api.rs
  2. 4 4
      apps/fortuna/src/command/run.rs

+ 4 - 4
apps/fortuna/src/api.rs

@@ -78,7 +78,7 @@ pub struct ApiState {
 
     pub explorer_metrics: Arc<ExplorerMetrics>,
 
-    pub config: Arc<Config>,
+    pub config: Config,
 }
 
 impl ApiState {
@@ -86,7 +86,7 @@ impl ApiState {
         chains: Arc<RwLock<HashMap<ChainId, ApiBlockChainState>>>,
         metrics_registry: Arc<RwLock<Registry>>,
         history: Arc<History>,
-        config: Arc<Config>,
+        config: &Config,
     ) -> ApiState {
         let metrics = ApiMetrics {
             http_requests: Family::default(),
@@ -354,7 +354,7 @@ mod test {
             Arc::new(RwLock::new(chains)),
             metrics_registry,
             Arc::new(History::new().await.unwrap()),
-            Arc::new(config),
+            &config,
         )
         .await;
 
@@ -678,7 +678,7 @@ mod test {
             Arc::new(RwLock::new(HashMap::new())),
             metrics_registry,
             Arc::new(History::new().await.unwrap()),
-            Arc::new(config),
+            &config,
         )
         .await;
 

+ 4 - 4
apps/fortuna/src/command/run.rs

@@ -28,7 +28,7 @@ pub async fn run_api(
     chains: Arc<RwLock<HashMap<String, ApiBlockChainState>>>,
     metrics_registry: Arc<RwLock<Registry>>,
     history: Arc<History>,
-    config: Arc<Config>,
+    config: &Config,
     mut rx_exit: watch::Receiver<bool>,
 ) -> Result<()> {
     #[derive(OpenApi)]
@@ -55,7 +55,7 @@ pub async fn run_api(
     )]
     struct ApiDoc;
 
-    let api_state = api::ApiState::new(chains, metrics_registry, history, config.clone()).await;
+    let api_state = api::ApiState::new(chains, metrics_registry, history, config).await;
 
     // Initialize Axum Router. Note the type here is a `Router<State>` due to the use of the
     // `with_state` method which replaces `Body` with `State` in the type signature.
@@ -87,7 +87,7 @@ pub async fn run_api(
 pub async fn run(opts: &RunOptions) -> Result<()> {
     // Load environment variables from a .env file if present
     let _ = dotenv::dotenv().map_err(|e| anyhow!("Failed to load .env file: {}", e))?;
-    let config = Arc::new(Config::load(&opts.config.config)?);
+    let config = Config::load(&opts.config.config)?;
     let secret = config.provider.secret.load()?.ok_or(anyhow!(
         "Please specify a provider secret in the config file."
     ))?;
@@ -171,7 +171,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
         chains.clone(),
         metrics_registry.clone(),
         history,
-        config.clone(),
+        &config,
         rx_exit,
     )
     .await?;