Additional, more informative routes (#1204)
* Have reward set updater run its own timer (#1200) * Have reward set updater run its own timer * Filter rocket log spam * Take last day of uptime for rewarding (#1202) * Take last day of uptime for rewarding * Rejigger calculations * Blacklist based on last 24 hr * Cleanup * Clippy * Additional, more informative routes * Improve blacklist updates * Fix rewards estimation
This commit is contained in:
@@ -2,41 +2,48 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::contract_cache::ValidatorCache;
|
||||
use mixnet_contract_common::{GatewayBond, MixNodeBond};
|
||||
use mixnet_contract_common::reward_params::EpochRewardParams;
|
||||
use mixnet_contract_common::{GatewayBond, Interval, MixNodeBond};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::State;
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[get("/mixnodes")]
|
||||
pub(crate) async fn get_mixnodes(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
pub async fn get_mixnodes(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
Json(cache.mixnodes().await)
|
||||
}
|
||||
|
||||
#[get("/gateways")]
|
||||
pub(crate) async fn get_gateways(cache: &State<ValidatorCache>) -> Json<Vec<GatewayBond>> {
|
||||
pub async fn get_gateways(cache: &State<ValidatorCache>) -> Json<Vec<GatewayBond>> {
|
||||
Json(cache.gateways().await)
|
||||
}
|
||||
|
||||
#[get("/mixnodes/rewarded")]
|
||||
pub(crate) async fn get_rewarded_set(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
pub async fn get_rewarded_set(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
Json(cache.rewarded_set().await.value)
|
||||
}
|
||||
|
||||
#[get("/mixnodes/active")]
|
||||
pub(crate) async fn get_active_set(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
pub async fn get_active_set(cache: &State<ValidatorCache>) -> Json<Vec<MixNodeBond>> {
|
||||
Json(cache.active_set().await.value)
|
||||
}
|
||||
|
||||
#[get("/mixnodes/blacklisted")]
|
||||
pub(crate) async fn get_blacklisted_mixnodes(
|
||||
cache: &State<ValidatorCache>,
|
||||
) -> Json<HashSet<String>> {
|
||||
pub async fn get_blacklisted_mixnodes(cache: &State<ValidatorCache>) -> Json<HashSet<String>> {
|
||||
Json(cache.mixnodes_blacklist().await.value)
|
||||
}
|
||||
|
||||
#[get("/gateways/blacklisted")]
|
||||
pub(crate) async fn get_blacklisted_gateways(
|
||||
cache: &State<ValidatorCache>,
|
||||
) -> Json<HashSet<String>> {
|
||||
pub async fn get_blacklisted_gateways(cache: &State<ValidatorCache>) -> Json<HashSet<String>> {
|
||||
Json(cache.gateways_blacklist().await.value)
|
||||
}
|
||||
|
||||
#[get("/epoch/reward_params")]
|
||||
pub async fn get_epoch_reward_params(cache: &State<ValidatorCache>) -> Json<EpochRewardParams> {
|
||||
Json(cache.epoch_reward_params().await.value)
|
||||
}
|
||||
|
||||
#[get("/epoch/current")]
|
||||
pub async fn get_current_epoch(cache: &State<ValidatorCache>) -> Json<Option<Interval>> {
|
||||
Json(cache.current_epoch().await.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user