Skip to main content

nym_api_requests/models/
performance.rs

1// Copyright 2026 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: GPL-3.0-only
3
4use crate::pagination::PaginatedResponse;
5use nym_contracts_common::Percent;
6use nym_performance_contract_common::{EpochId, KindMedians, LatestPerformance, NodeId};
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9use tendermint::block::Height;
10use time::OffsetDateTime;
11use utoipa::ToSchema;
12
13#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
14pub struct PerformanceEntriesRecordsResponse {
15    /// The height every entry was pinned to - the same height the client obtained a quorum'd
16    /// snapshot for.
17    #[schema(value_type = String)]
18    pub height: Height,
19
20    pub entries: PaginatedResponse<LatestPerformance>,
21}
22
23#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, ToSchema)]
24pub struct NodePerformanceResponseV3 {
25    pub node_id: NodeId,
26
27    /// Absent when the node has no committed entry in the latest settled snapshot's bond set.
28    pub performance: Option<DetailedNodePerformanceV3>,
29}
30
31/// A node's committed performance entry, with its bundle's medians read beside it without proof.
32#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, ToSchema)]
33pub struct DetailedNodePerformanceV3 {
34    /// The committed score; absent when the contract could not score the bundle.
35    #[schema(value_type = Option<String>)]
36    pub performance_score: Option<Percent>,
37
38    /// The performance contract epoch the score comes from.
39    pub source_epoch: EpochId,
40
41    /// The block time of the snapshot height the entry was read at.
42    #[serde(with = "time::serde::rfc3339")]
43    #[schemars(with = "String")]
44    #[schema(value_type = String)]
45    pub computed_at: OffsetDateTime,
46
47    /// The bundle's medians; absent for an entry older than the epoch before the newest.
48    pub medians: Option<KindMedians>,
49}