explorer-api: add API resource to show the delegations for each mix node

This commit is contained in:
Mark Sinclair
2021-09-13 10:33:41 +01:00
parent 0b9c03ca90
commit cba3625394
3 changed files with 40 additions and 5 deletions
+8 -2
View File
@@ -6,11 +6,11 @@ use serde::Serialize;
use mixnet_contract::{Addr, Coin, Layer, MixNode};
use crate::mix_node::models::{NodeDescription, NodeStats};
use crate::mix_nodes::Location;
use crate::mix_nodes::{get_mixnode_delegations, Location};
use crate::state::ExplorerApiStateContext;
pub fn mix_node_make_default_routes() -> Vec<Route> {
routes_with_openapi![get_description, get_stats, list]
routes_with_openapi![get_delegations, get_description, get_stats, list]
}
#[derive(Clone, Debug, Serialize, JsonSchema)]
@@ -51,6 +51,12 @@ pub(crate) async fn list(
)
}
#[openapi(tag = "mix_node")]
#[get("/<pubkey>/delegations")]
pub(crate) async fn get_delegations(pubkey: &str) -> Json<Vec<mixnet_contract::Delegation>> {
Json(get_mixnode_delegations(pubkey).await)
}
#[openapi(tag = "mix_node")]
#[get("/<pubkey>/description")]
pub(crate) async fn get_description(