Skip to main content

ic_query/nns/node_provider/report/model/
report.rs

1#[cfg(feature = "nns-host")]
2use crate::cache_file::JsonCacheReport;
3use serde::{Deserialize, Serialize};
4
5///
6/// NnsNodeProviderListReport
7///
8/// Complete NNS node provider inventory report with source metadata.
9///
10
11#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
12pub struct NnsNodeProviderListReport {
13    pub schema_version: u32,
14    pub network: String,
15    pub governance_canister_id: String,
16    pub registry_canister_id: String,
17    pub registry_version: u64,
18    pub fetched_at: String,
19    pub source_endpoint: String,
20    pub fetched_by: String,
21    pub node_provider_count: usize,
22    pub node_providers: Vec<NnsNodeProviderRow>,
23}
24
25#[cfg(feature = "nns-host")]
26impl JsonCacheReport for NnsNodeProviderListReport {
27    fn schema_version(&self) -> u32 {
28        self.schema_version
29    }
30
31    fn network(&self) -> &str {
32        &self.network
33    }
34}
35
36#[cfg(feature = "nns-host")]
37impl_nns_inventory_report!(
38    NnsNodeProviderListReport,
39    super::super::NNS_NODE_PROVIDER_LIST_REPORT_SCHEMA_VERSION,
40    "node_provider",
41    node_provider_count,
42    node_providers,
43    |report: &NnsNodeProviderListReport| Some(report.governance_canister_id.clone()),
44    |report: &NnsNodeProviderListReport| {
45        if report.governance_canister_id != crate::nns::MAINNET_GOVERNANCE_CANISTER_ID {
46            return Err(format!(
47                "governance_canister_id is {}, expected {}",
48                report.governance_canister_id,
49                crate::nns::MAINNET_GOVERNANCE_CANISTER_ID
50            ));
51        }
52        Ok(())
53    },
54);
55
56///
57/// NnsNodeProviderRow
58///
59/// One node provider row projected from governance and registry data.
60///
61
62#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
63pub struct NnsNodeProviderRow {
64    pub node_provider_principal: String,
65    pub name: Option<String>,
66    pub node_count: Option<u32>,
67    pub reward_account_hex: Option<String>,
68}
69
70///
71/// NnsNodeProviderInfoReport
72///
73/// Detailed report for one resolved NNS node provider.
74///
75
76#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
77pub struct NnsNodeProviderInfoReport {
78    pub schema_version: u32,
79    pub input: String,
80    pub resolved_from: String,
81    pub network: String,
82    pub governance_canister_id: String,
83    pub registry_canister_id: String,
84    pub registry_version: u64,
85    pub fetched_at: String,
86    pub source_endpoint: String,
87    pub fetched_by: String,
88    pub node_provider_principal: String,
89    pub name: Option<String>,
90    pub node_count: Option<u32>,
91    pub reward_account_hex: Option<String>,
92}