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