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, CatalogAuthorityEvidence, CatalogLoadOutcome, CatalogReadPolicy,
20    CatalogSourceSelection, SubnetCatalogCacheRequest, SubnetCatalogErrorCategory,
21    SubnetCatalogErrorCode, SubnetCatalogHostError, SubnetCatalogLoadRequest,
22    SubnetCatalogRefreshRequest, SubnetCatalogRemediation, SubnetCatalogRetryability,
23    SubnetCatalogSource, SubnetCatalogSourceFuture, fetch_subnet_catalog_async,
24    load_cached_subnet_catalog, load_subnet_catalog, load_subnet_catalog_async,
25    load_subnet_catalog_with_source, load_subnet_catalog_with_source_async, refresh_subnet_catalog,
26    refresh_subnet_catalog_async, refresh_subnet_catalog_with_source,
27    refresh_subnet_catalog_with_source_async, subnet_catalog_path,
28    subnet_catalog_refresh_lock_path,
29};
30pub use json::{catalog_to_pretty_json, parse_catalog_json};
31#[cfg(feature = "subnet-catalog-host")]
32pub use model::UncertifiedCatalogCollection;
33#[cfg(feature = "subnet-catalog-host")]
34pub(in crate::subnet_catalog) use model::catalog_agreement_digest;
35pub use model::{
36    CLASSIFICATION_SCHEMA_VERSION, CatalogAssurance, CatalogValidationContext,
37    ClassificationSource, GeographicScope, RESOLVER_SCHEMA_VERSION, RawSubnetCatalog, RoutingRange,
38    SubnetCatalogProvenance, SubnetInfo, SubnetKind, SubnetSpecialization, ValidatedSubnetCatalog,
39};
40pub use principal::canonical_principal_text;
41pub(crate) use principal::{parse_principal, principal_bytes};
42#[cfg(feature = "subnet-catalog-host")]
43pub use report::{
44    CatalogStaleStatus, SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
45    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
46    SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
47    build_subnet_catalog_info_report_with_source, build_subnet_catalog_list_report,
48    build_subnet_catalog_list_report_with_source,
49};
50pub use resolver::{ResolveAs, ResolvedCanisterRoute, ResolvedSubnet, ResolvedSubnetSubject};
51#[cfg(feature = "subnet-catalog-host")]
52pub use text::{
53    subnet_catalog_info_report_text, subnet_catalog_list_report_text,
54    subnet_catalog_list_report_verbose_text, subnet_catalog_refresh_report_text,
55};
56#[cfg(feature = "subnet-catalog-host")]
57pub use time::catalog_stale_status;
58pub(crate) use time::format_utc_timestamp_secs;
59#[cfg(any(
60    feature = "dashboard-host",
61    feature = "icrc-host",
62    feature = "subnet-catalog-host"
63))]
64pub(crate) use time::parse_utc_timestamp_secs;
65
66pub const CATALOG_SCHEMA_VERSION: u32 = 2;
67pub const MAINNET_NETWORK: &str = "ic";
68pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
69#[cfg(feature = "subnet-catalog-host")]
70/// Maximum future timestamp skew accepted by default during catalog validation.
71pub const DEFAULT_CATALOG_MAX_FUTURE_SKEW_SECONDS: u64 = 5 * 60;
72#[cfg(feature = "subnet-catalog-host")]
73pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
74#[cfg(feature = "subnet-catalog-host")]
75pub const DEFAULT_REFRESH_LOCK_STALE_SECONDS: u64 = 30 * 60;
76#[cfg(feature = "subnet-catalog-host")]
77pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
78#[cfg(feature = "subnet-catalog-host")]
79/// Minimum number of independent hosts required for endpoint agreement.
80pub const MIN_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 2;
81#[cfg(feature = "subnet-catalog-host")]
82/// Maximum number of endpoints accepted by one bounded agreement collection.
83pub const MAX_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 3;
84#[cfg(feature = "subnet-catalog-host")]
85pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 2;
86#[cfg(feature = "subnet-catalog-host")]
87pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 2;
88#[cfg(feature = "subnet-catalog-host")]
89pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 2;
90
91#[cfg(test)]
92mod core_tests;
93#[cfg(all(test, feature = "subnet-catalog-host"))]
94mod tests;