Skip to main content

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

1#[cfg(feature = "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 = "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 = "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| {
44        if report.governance_canister_id != crate::ic_registry::MAINNET_GOVERNANCE_CANISTER_ID {
45            return Err(format!(
46                "governance_canister_id is {}, expected {}",
47                report.governance_canister_id,
48                crate::ic_registry::MAINNET_GOVERNANCE_CANISTER_ID
49            ));
50        }
51        Ok(())
52    },
53);
54
55///
56/// NnsNodeProviderRow
57///
58/// One node provider row projected from governance and registry data.
59///
60
61#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
62pub struct NnsNodeProviderRow {
63    pub node_provider_principal: String,
64    pub name: Option<String>,
65    pub node_count: Option<u32>,
66    pub reward_account_hex: Option<String>,
67}
68
69///
70/// NnsNodeProviderInfoReport
71///
72/// Detailed report for one resolved NNS node provider.
73///
74
75#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
76pub struct NnsNodeProviderInfoReport {
77    pub schema_version: u32,
78    pub input: String,
79    pub resolved_from: String,
80    pub network: String,
81    pub governance_canister_id: String,
82    pub registry_canister_id: String,
83    pub registry_version: u64,
84    pub fetched_at: String,
85    pub source_endpoint: String,
86    pub fetched_by: String,
87    pub node_provider_principal: String,
88    pub name: Option<String>,
89    pub node_count: Option<u32>,
90    pub reward_account_hex: Option<String>,
91}
92
93///
94/// NnsNodeProviderRefreshReport
95///
96/// Outcome of refreshing the cached NNS node provider inventory.
97///
98
99#[cfg(feature = "host")]
100#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
101pub struct NnsNodeProviderRefreshReport {
102    pub schema_version: u32,
103    pub network: String,
104    pub cache_path: String,
105    pub refresh_lock_path: String,
106    pub output_path: Option<String>,
107    pub governance_canister_id: String,
108    pub registry_canister_id: String,
109    pub registry_version: u64,
110    pub fetched_at: String,
111    pub source_endpoint: String,
112    pub fetched_by: String,
113    pub dry_run: bool,
114    pub wrote_cache: bool,
115    pub replaced_existing_cache: bool,
116    pub node_provider_count: usize,
117}