[Stats API] Infallible network view (#5825)

* infallible network view and cheddar model for current compatibility

* bump patch version

* typo
This commit is contained in:
Simon Wicky
2025-06-04 17:08:44 +02:00
committed by GitHub
parent a7d6cba11d
commit be16fddc75
4 changed files with 806 additions and 371 deletions
Generated
+779 -357
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-statistics-api"
version = "0.1.0"
version = "0.1.1"
authors.workspace = true
repository.workspace = true
homepage.workspace = true
@@ -39,7 +39,6 @@ utoipauto.workspace = true
#internal
nym-bin-common = { path = "../common/bin-common" }
nym-http-api-client = { path = "../common/http-api-client" }
nym-http-api-common = { path = "../common/http-api-common", features = [
"middleware",
] }
@@ -47,7 +46,9 @@ nym-statistics-common = { path = "../common/statistics", features = [
"openapi",
] }
nym-task = { path = "../common/task" }
nym-validator-client = { path = "../common/client-libs/validator-client" }
nym-http-api-client = { git = "https://github.com/nymtech/nym", branch = "release/2025.11-cheddar" }
nym-validator-client = { git = "https://github.com/nymtech/nym", branch = "release/2025.11-cheddar" } # current develop is incompatible with current deployed API
[build-dependencies]
anyhow = { workspace = true }
+1 -1
View File
@@ -33,7 +33,7 @@ async fn main() -> anyhow::Result<()> {
args.nym_api_url,
shutdown_manager.child_token("network-refresher"),
)
.await?;
.await;
let http_server =
http::server::build_http_api(storage, network_refresher.network_view(), args.http_port)
+22 -10
View File
@@ -71,15 +71,15 @@ impl NetworkRefresher {
pub(crate) async fn initialise_new(
maybe_nym_api_url: Option<Url>,
shutdown_token: ShutdownToken,
) -> Result<Self> {
) -> Self {
let node_querier = match maybe_nym_api_url {
Some(url) => Some(NodesQuerier {
client: nym_http_api_client::Client::builder::<_, anyhow::Error>(url)?
.no_hickory_dns()
.with_user_agent("node-statistics-api")
.build::<anyhow::Error>()?
.into(),
}),
Some(url) => match Self::build_http_api_client(url) {
Ok(client) => Some(NodesQuerier { client }),
Err(e) => {
warn!("Failed to build Nym API client, no network view will be availabe : {e}");
None
}
},
None => {
warn!("No Nym API specified, network view is unavailable");
None
@@ -93,8 +93,20 @@ impl NetworkRefresher {
network: NetworkView::new_empty(),
};
this.refresh_network_nodes().await?;
Ok(this)
if let Err(e) = this.refresh_network_nodes().await {
warn!("Failed to fetch initial network nodes : {e}");
}
this
}
fn build_http_api_client(url: Url) -> Result<NymApiClient> {
Ok(
nym_http_api_client::Client::builder::<_, anyhow::Error>(url)?
.no_hickory_dns()
.with_user_agent("node-statistics-api")
.build::<anyhow::Error>()?
.into(),
)
}
async fn refresh_network_nodes(&mut self) -> Result<()> {