-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/lambdaclass_gas_oracle' into r…
…emove-token-fetcher-singleton
- Loading branch information
Showing
3 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use axum::{extract, extract::Json, routing::get, Router}; | ||
use tokio::sync::watch; | ||
use zksync_config::configs::native_token_fetcher::NativeTokenFetcherConfig; | ||
|
||
pub(crate) async fn run_server( | ||
mut stop_receiver: watch::Receiver<bool>, | ||
server_configs: &NativeTokenFetcherConfig, | ||
) -> anyhow::Result<()> { | ||
let app = Router::new().route("/conversion_rate/:token_address", get(get_conversion_rate)); | ||
|
||
let bind_address = if server_configs.host.starts_with("http://") { | ||
&server_configs.host[7..] // If it starts with "http://", strip the prefix | ||
} else { | ||
&server_configs.host // Otherwise, return the original string | ||
}; | ||
|
||
axum::Server::bind(&bind_address.parse().expect("Unable to parse socket address")) | ||
.serve(app.into_make_service()) | ||
.with_graceful_shutdown(async move { | ||
if stop_receiver.changed().await.is_err() { | ||
tracing::warn!("Stop signal sender for conversion rate API server was dropped without sending a signal"); | ||
} | ||
tracing::info!("Stop signal received, conversion rate server is shutting down"); | ||
}) | ||
.await | ||
.expect("Conversion rate server failed"); | ||
tracing::info!("Conversion rate server shut down"); | ||
Ok(()) | ||
} | ||
|
||
// basic handler that responds with a static string | ||
async fn get_conversion_rate(extract::Path(_token_address): extract::Path<String>) -> Json<u64> { | ||
tracing::info!("Received request for conversion rate"); | ||
Json(42) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.