15c3012199
* explorer-api: add nym node endpoints + UI to show nym-nodes and account balances * explorer-api: add endpoints to get operator rewards explorer-ui: show delegations on nym-nodes, show operator rewards, bug fixes * explorer-ui: change summary screen to only show nym-node stats * explorer-api: add unstable routes to get legacy mixnodes and gateways from the contract instead of the Nym API explorer-ui: adapt front-end to show less information in legacy nodes with plain bond types * explorer-ui: fix up source of legacy mixnode data * explorer-ui: add more account page null and undefined checks * explorer-ui: filter out null gateway versions * explorer-ui: sanitise gateway versions * explorer-ui: add more guards on the balance parts to check that greater than 0 * explorer-api: make /tmp/unstable/gateways endpoint compatible with the current Harbour Master API * explorer-ui: fix typo * cargo fmt * Add node-id, total stake and links to nodes list --------- Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com> Co-authored-by: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com>
57 lines
1.7 KiB
Rust
57 lines
1.7 KiB
Rust
use nym_validator_client::models::NymNodeData;
|
|
use rocket::serde::json::Json;
|
|
use rocket::{Route, State};
|
|
use rocket_okapi::okapi::openapi3::OpenApi;
|
|
use rocket_okapi::openapi_get_routes_spec;
|
|
use rocket_okapi::settings::OpenApiSettings;
|
|
|
|
use crate::mix_nodes::http::get_mixnode_summary;
|
|
use crate::overview::models::{NymNodeSummary, OverviewSummary, RoleSummary};
|
|
use crate::state::ExplorerApiStateContext;
|
|
|
|
pub fn overview_make_default_routes(settings: &OpenApiSettings) -> (Vec<Route>, OpenApi) {
|
|
openapi_get_routes_spec![settings: summary]
|
|
}
|
|
|
|
fn get_nym_nodes_by_role(nodes: &Vec<NymNodeData>) -> RoleSummary {
|
|
let mut summary = RoleSummary::default();
|
|
|
|
for node in nodes {
|
|
if node.declared_role.entry {
|
|
summary.entry += 1;
|
|
}
|
|
if node.declared_role.exit_ipr {
|
|
summary.exit_ipr += 1;
|
|
}
|
|
if node.declared_role.exit_nr {
|
|
summary.exit_nr += 1;
|
|
}
|
|
if node.declared_role.mixnode {
|
|
summary.mixnode += 1;
|
|
}
|
|
}
|
|
|
|
summary
|
|
}
|
|
|
|
#[openapi(tag = "overview")]
|
|
#[get("/summary")]
|
|
pub(crate) async fn summary(state: &State<ExplorerApiStateContext>) -> Json<OverviewSummary> {
|
|
let nym_nodes = state
|
|
.inner
|
|
.nymnodes
|
|
.get_bonded_nymnodes_descriptions()
|
|
.await;
|
|
let roles = get_nym_nodes_by_role(&nym_nodes);
|
|
|
|
Json(OverviewSummary {
|
|
mixnodes: get_mixnode_summary(state).await,
|
|
validators: state.inner.validators.get_validator_summary().await,
|
|
gateways: state.inner.gateways.get_gateway_summary().await,
|
|
nymnodes: NymNodeSummary {
|
|
count: nym_nodes.len(),
|
|
roles,
|
|
},
|
|
})
|
|
}
|