#[cfg(feature = "ic-state-host")]
use crate::runtime::RuntimeError;
use serde::Serialize;
#[cfg(feature = "ic-state-host")]
use thiserror::Error as ThisError;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcApiBoundaryNodeRequest {
pub source_endpoint: String,
pub now_unix_secs: u64,
}
impl IcApiBoundaryNodeRequest {
#[must_use]
pub fn new(source_endpoint: impl Into<String>, now_unix_secs: u64) -> Self {
Self {
source_endpoint: source_endpoint.into(),
now_unix_secs,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct IcCertifiedStateProvenance {
pub schema_version: u32,
pub network: String,
pub authority: String,
pub source_endpoint: String,
pub effective_canister_id: String,
pub fetched_at_unix_seconds: u64,
pub fetched_at: String,
pub fetched_by: String,
pub certificate_time_unix_nanos: u64,
pub certificate_time_unix_seconds: u64,
pub certificate_time: String,
pub certified: bool,
pub point_in_time_guaranteed: bool,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct IcApiBoundaryNodeRow {
pub node_id: String,
pub domain: String,
pub ipv4_address: Option<String>,
pub ipv6_address: String,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct IcApiBoundaryNodeReport {
#[serde(flatten)]
pub provenance: IcCertifiedStateProvenance,
pub node_count: usize,
pub rows: Vec<IcApiBoundaryNodeRow>,
}
#[cfg(feature = "ic-state-host")]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcApiBoundaryNodeSourceRequest {
pub network: String,
pub endpoint: String,
pub effective_canister_id: String,
pub observed_at_unix_seconds: u64,
pub fetched_at: String,
pub fetched_by: String,
}
#[cfg(feature = "ic-state-host")]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IcApiBoundaryNodeSourceData {
pub source: IcApiBoundaryNodeSourceRequest,
pub certificate_time_unix_nanos: u64,
pub rows: Vec<IcApiBoundaryNodeRow>,
}
#[cfg(feature = "ic-state-host")]
#[derive(Debug, ThisError)]
pub enum IcApiBoundaryNodeHostError {
#[error("failed to run certified IC state query: {0}")]
Runtime(#[from] RuntimeError),
#[error("failed to build IC state agent for {endpoint}: {reason}")]
AgentBuild {
endpoint: String,
reason: String,
},
#[error("certified IC state read through {endpoint} failed: {reason}")]
CertifiedReadState {
endpoint: String,
reason: String,
},
#[error("invalid certified IC state-tree data: {reason}")]
InvalidCertifiedState {
reason: String,
},
#[error("invalid API boundary-node source data: {reason}")]
InvalidSourceData {
reason: String,
},
}