Skip to content

Commit aee6404

Browse files
committed
fix
1 parent 57ba820 commit aee6404

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

apps/fortuna/src/api.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,15 @@ pub struct ApiState {
7878

7979
pub explorer_metrics: Arc<ExplorerMetrics>,
8080

81-
/// Parsed configuration
82-
pub config: Config,
81+
pub config: Arc<Config>,
8382
}
8483

8584
impl ApiState {
8685
pub async fn new(
8786
chains: Arc<RwLock<HashMap<ChainId, ApiBlockChainState>>>,
8887
metrics_registry: Arc<RwLock<Registry>>,
8988
history: Arc<History>,
90-
config: Config,
89+
config: Arc<Config>,
9190
) -> ApiState {
9291
let metrics = ApiMetrics {
9392
http_requests: Family::default(),
@@ -108,7 +107,7 @@ impl ApiState {
108107
explorer_metrics,
109108
history,
110109
metrics_registry,
111-
config,
110+
config: config.clone(),
112111
}
113112
}
114113
}

apps/fortuna/src/command/run.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub async fn run_api(
2828
chains: Arc<RwLock<HashMap<String, ApiBlockChainState>>>,
2929
metrics_registry: Arc<RwLock<Registry>>,
3030
history: Arc<History>,
31-
config: Config,
31+
config: Arc<Config>,
3232
mut rx_exit: watch::Receiver<bool>,
3333
) -> Result<()> {
3434
#[derive(OpenApi)]
@@ -55,7 +55,7 @@ pub async fn run_api(
5555
)]
5656
struct ApiDoc;
5757

58-
let api_state = api::ApiState::new(chains, metrics_registry, history, config).await;
58+
let api_state = api::ApiState::new(chains, metrics_registry, history, config.clone()).await;
5959

6060
// Initialize Axum Router. Note the type here is a `Router<State>` due to the use of the
6161
// `with_state` method which replaces `Body` with `State` in the type signature.
@@ -87,7 +87,7 @@ pub async fn run_api(
8787
pub async fn run(opts: &RunOptions) -> Result<()> {
8888
// Load environment variables from a .env file if present
8989
let _ = dotenv::dotenv().map_err(|e| anyhow!("Failed to load .env file: {}", e))?;
90-
let config = Config::load(&opts.config.config)?;
90+
let config = Arc::new(Config::load(&opts.config.config)?);
9191
let secret = config.provider.secret.load()?.ok_or(anyhow!(
9292
"Please specify a provider secret in the config file."
9393
))?;
@@ -171,7 +171,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
171171
chains.clone(),
172172
metrics_registry.clone(),
173173
history,
174-
config,
174+
config.clone(),
175175
rx_exit,
176176
)
177177
.await?;

0 commit comments

Comments
 (0)