skeleton of changes for nym api batch requests

This commit is contained in:
jmwample
2025-03-03 16:45:38 -07:00
parent 65166bfd61
commit 12ed915069
4 changed files with 77 additions and 17 deletions
@@ -498,6 +498,11 @@ impl NymApiClient {
Ok(nodes)
}
/// retrieve basic information for all bonded nodes on the network
pub async fn retrieve_basic_nodes_batch(&self, node_ids: Vec<u32>) -> Result<Vec<SkimmedNode>, ValidatorClientError> {
Ok(self.nym_api.retrieve_basic_nodes_batch(&node_ids).await?.nodes)
}
pub async fn health(&self) -> Result<ApiHealthResponse, ValidatorClientError> {
Ok(self.nym_api.health().await?)
}
@@ -270,10 +270,10 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"mixnodes",
"skimmed",
routes::SKIMMED,
],
NO_PARAMS,
)
@@ -286,10 +286,10 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"gateways",
"skimmed",
routes::SKIMMED,
],
NO_PARAMS,
)
@@ -335,9 +335,9 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"skimmed",
routes::SKIMMED,
"entry-gateways",
"all",
],
@@ -372,9 +372,9 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"skimmed",
routes::SKIMMED,
"mixnodes",
"active",
],
@@ -409,9 +409,9 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"skimmed",
routes::SKIMMED,
"mixnodes",
"all",
],
@@ -420,6 +420,31 @@ pub trait NymApiClientExt: ApiClient {
.await
}
/// Send a Post request with a set of node ids. A successful response will contain descriptors
/// for all nodes associated with those node IDs available in the current full topology.
///
/// If a provided node ID is not present there will be no descriptor for that node in the response.
///
/// If no node IDs are provided the response will contain no descriptors.
#[instrument(level = "debug", skip(self))]
async fn retrieve_basic_nodes_batch(
&self,
node_ids: &[NodeId],
) -> Result<CachedNodesResponse<SkimmedNode>, NymAPIError> {
self.post_json(
&[
routes::API_VERSION,
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
routes::SKIMMED,
routes::BATCH,
],
NO_PARAMS,
node_ids,
)
.await
}
#[instrument(level = "debug", skip(self))]
async fn get_basic_nodes(
&self,
@@ -444,9 +469,9 @@ pub trait NymApiClientExt: ApiClient {
self.get_json(
&[
routes::API_VERSION,
"unstable",
routes::UNSTABLE,
routes::NYM_NODES_ROUTES,
"skimmed",
routes::SKIMMED,
],
&params,
)
@@ -74,3 +74,7 @@ pub const SERVICE_PROVIDERS: &str = "services";
pub const DETAILS: &str = "details";
pub const CHAIN_STATUS: &str = "chain-status";
pub const NETWORK: &str = "network";
pub const UNSTABLE: &str = "unstable";
pub const SKIMMED: &str = "skimmed";
pub const BATCH: &str = "batch";