aggregate new data with nym-api

This commit is contained in:
Jędrzej Stuczyński
2024-05-20 11:06:14 +01:00
parent 3077c2ea8d
commit 7a416f8cf5
3 changed files with 17 additions and 2 deletions
+5 -1
View File
@@ -10,7 +10,7 @@ use nym_mixnet_contract_common::rewarding::RewardEstimate;
use nym_mixnet_contract_common::{
GatewayBond, IdentityKey, Interval, MixId, MixNode, Percent, RewardedSetNodeStatus,
};
use nym_node_requests::api::v1::node::models::BinaryBuildInformationOwned;
use nym_node_requests::api::v1::node::models::{AuxiliaryDetails, BinaryBuildInformationOwned};
use schemars::gen::SchemaGenerator;
use schemars::schema::{InstanceType, Schema, SchemaObject};
use schemars::JsonSchema;
@@ -483,6 +483,7 @@ impl JsonSchema for OffsetDateTimeJsonSchemaWrapper {
}
}
// this struct is getting quite bloated...
#[derive(Clone, Debug, Serialize, Deserialize, schemars::JsonSchema)]
pub struct NymNodeDescription {
#[serde(default)]
@@ -490,6 +491,9 @@ pub struct NymNodeDescription {
pub host_information: HostInformation,
#[serde(default)]
pub auxiliary_details: AuxiliaryDetails,
// TODO: do we really care about ALL build info or just the version?
pub build_information: BinaryBuildInformationOwned,
+6
View File
@@ -146,6 +146,11 @@ async fn get_gateway_description(
source: err,
})?;
// this can be an old node that hasn't yet exposed this
let auxiliary_details = client.get_auxiliary_details().await.inspect_err(|err| {
debug!("could not obtain auxiliary details of gateway {}: {err} is it running an old version?", gateway.identity_key);
}).unwrap_or_default();
let websockets =
client
.get_mixnet_websockets()
@@ -188,6 +193,7 @@ async fn get_gateway_description(
network_requester,
ip_packet_router,
mixnet_websockets: websockets.into(),
auxiliary_details,
};
Ok((gateway.identity_key, description))
+6 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
use crate::api::v1::gateway::models::WebSockets;
use crate::api::v1::node::models::SignedHostInformation;
use crate::api::v1::node::models::{AuxiliaryDetails, SignedHostInformation};
use crate::api::ErrorResponse;
use crate::routes;
use async_trait::async_trait;
@@ -37,6 +37,11 @@ pub trait NymNodeApiClientExt: ApiClient {
.await
}
async fn get_auxiliary_details(&self) -> Result<AuxiliaryDetails, NymNodeApiClientError> {
self.get_json_from(routes::api::v1::auxiliary_absolute())
.await
}
// TODO: implement calls for other endpoints; for now I only care about the wss
async fn get_mixnet_websockets(&self) -> Result<WebSockets, NymNodeApiClientError> {
self.get_json_from(