// Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use crate::cache::ValidatorCache; use mixnet_contract::{GatewayBond, MixNodeBond}; use rocket::serde::json::Json; use rocket::State; #[get("/mixnodes")] pub(crate) async fn get_mixnodes(cache: &State) -> Json> { Json(cache.mixnodes().await.value) } #[get("/gateways")] pub(crate) async fn get_gateways(cache: &State) -> Json> { Json(cache.gateways().await.value) } #[get("/mixnodes/active")] pub(crate) async fn get_active_mixnodes( cache: &State, ) -> Option>> { cache.active_mixnodes().await.map(|cache| Json(cache.value)) } #[get("/gateways/active")] pub(crate) async fn get_active_gateways( cache: &State, ) -> Option>> { cache.active_gateways().await.map(|cache| Json(cache.value)) }