da9d743f39
* axum-equivalent mixnode http api routes * replaced all rocket routes with axum equivalents * removed '_axum' suffix from the routes
29 lines
909 B
Rust
29 lines
909 B
Rust
use axum::extract::{Query, State};
|
|
use nym_mixnode_common::verloc::{AtomicVerlocResult, VerlocResult};
|
|
use nym_node::http::api::{FormattedResponse, OutputParams};
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct VerlocState {
|
|
shared: AtomicVerlocResult,
|
|
}
|
|
|
|
impl VerlocState {
|
|
pub fn new(atomic_verloc_result: AtomicVerlocResult) -> Self {
|
|
VerlocState {
|
|
shared: atomic_verloc_result,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Provides verifiable location (verloc) measurements for this mixnode - a list of the
|
|
/// round-trip times, in milliseconds, for all other mixnodes that this node knows about.
|
|
pub(crate) async fn verloc(
|
|
State(verloc): State<VerlocState>,
|
|
Query(output): Query<OutputParams>,
|
|
) -> MixnodeVerlocResponse {
|
|
let output = output.output.unwrap_or_default();
|
|
output.to_response(verloc.shared.clone_data().await)
|
|
}
|
|
|
|
pub type MixnodeVerlocResponse = FormattedResponse<VerlocResult>;
|