Skip to main content

ic_query/subnet_catalog/
mod.rs

1//! Cached NNS subnet catalog models, resolution helpers, builders, and renderers.
2
3mod error;
4#[cfg(feature = "subnet-catalog-host")]
5mod host;
6mod json;
7mod model;
8mod principal;
9#[cfg(feature = "subnet-catalog-host")]
10mod report;
11mod resolver;
12#[cfg(feature = "subnet-catalog-host")]
13mod text;
14mod time;
15
16pub use error::CatalogError;
17#[cfg(feature = "subnet-catalog-host")]
18pub use host::{
19    CacheDisposition, CatalogLoadOutcome, CatalogReadPolicy, SubnetCatalogCacheRequest,
20    SubnetCatalogErrorCategory, SubnetCatalogErrorCode, SubnetCatalogHostError,
21    SubnetCatalogLoadRequest, SubnetCatalogRefreshRequest, SubnetCatalogRemediation,
22    SubnetCatalogRetryability, SubnetCatalogSource, fetch_subnet_catalog_async,
23    load_cached_subnet_catalog, load_subnet_catalog, load_subnet_catalog_with_source,
24    refresh_subnet_catalog, refresh_subnet_catalog_with_source, subnet_catalog_path,
25    subnet_catalog_refresh_lock_path,
26};
27pub use json::{catalog_to_pretty_json, parse_catalog_json};
28pub use model::{
29    CLASSIFICATION_SCHEMA_VERSION, CatalogAssurance, CatalogValidationContext,
30    ClassificationSource, GeographicScope, RESOLVER_SCHEMA_VERSION, RawSubnetCatalog, RoutingRange,
31    SubnetCatalogProvenance, SubnetInfo, SubnetKind, SubnetSpecialization, ValidatedSubnetCatalog,
32};
33pub use principal::canonical_principal_text;
34pub(crate) use principal::{parse_principal, principal_bytes};
35#[cfg(feature = "subnet-catalog-host")]
36pub use report::{
37    CatalogStaleStatus, SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
38    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
39    SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
40    build_subnet_catalog_info_report_with_source, build_subnet_catalog_list_report,
41    build_subnet_catalog_list_report_with_source,
42};
43pub use resolver::{ResolveAs, ResolvedCanisterRoute, ResolvedSubnet, ResolvedSubnetSubject};
44#[cfg(feature = "subnet-catalog-host")]
45pub use text::{
46    subnet_catalog_info_report_text, subnet_catalog_list_report_text,
47    subnet_catalog_list_report_verbose_text, subnet_catalog_refresh_report_text,
48};
49#[cfg(feature = "subnet-catalog-host")]
50pub use time::catalog_stale_status;
51pub(crate) use time::format_utc_timestamp_secs;
52#[cfg(feature = "subnet-catalog-host")]
53pub(crate) use time::parse_utc_timestamp_secs;
54
55pub const CATALOG_SCHEMA_VERSION: u32 = 1;
56pub const MAINNET_NETWORK: &str = "ic";
57pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
58#[cfg(feature = "subnet-catalog-host")]
59/// Maximum future timestamp skew accepted by default during catalog validation.
60pub const DEFAULT_CATALOG_MAX_FUTURE_SKEW_SECONDS: u64 = 5 * 60;
61#[cfg(feature = "subnet-catalog-host")]
62pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
63#[cfg(feature = "subnet-catalog-host")]
64pub const DEFAULT_REFRESH_LOCK_STALE_SECONDS: u64 = 30 * 60;
65#[cfg(feature = "subnet-catalog-host")]
66pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
67#[cfg(feature = "subnet-catalog-host")]
68pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
69#[cfg(feature = "subnet-catalog-host")]
70pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
71#[cfg(feature = "subnet-catalog-host")]
72pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 1;
73
74#[cfg(test)]
75mod core_tests;
76#[cfg(all(test, feature = "subnet-catalog-host"))]
77mod tests;