pub struct Subnet { /* private fields */ }Expand description
Information about a subnet, including its public key, member nodes, and assigned canister ranges.
Range information may be incomplete depending on how the subnet was fetched. The lack of a canister ID
within assigned ranges should not be treated immediately as an authorization failure without fetching
fresh data with Agent::fetch_subnet_by_canister.
Conversely, the presence of a canister ID within the ranges is only authoritative when the
subnet was fetched by canister. A subnet fetched by ID via
Agent::fetch_subnet_by_id reports ranges that it attested
itself. Use Agent::fetch_subnet_by_canister to
decide whether a subnet may speak for a canister.
Implementations§
Source§impl Subnet
impl Subnet
Sourcepub fn contains_canister(&self, canister_id: &Principal) -> bool
pub fn contains_canister(&self, canister_id: &Principal) -> bool
Checks whether the given canister ID is contained within the subnet’s assigned canister ranges.
Note that this is not authoritative if the subnet was fetched by subnet ID; see the type-level documentation.
Sourcepub fn iter_canister_ranges(&self) -> CanisterRangesIter<'_> ⓘ
pub fn iter_canister_ranges(&self) -> CanisterRangesIter<'_> ⓘ
Returns an iterator over the known canister ID ranges assigned to this subnet.
Note that these are self-reported, and so not authoritative, if the subnet was fetched by subnet ID; see the type-level documentation.
Sourcepub fn self_reported_key(&self) -> &[u8] ⓘ
pub fn self_reported_key(&self) -> &[u8] ⓘ
Returns the self-reported public key of the subnet.
Note that this key is not authoritative if the subnet is rogue.
Sourcepub fn contains_node(&self, node_id: &Principal) -> bool
pub fn contains_node(&self, node_id: &Principal) -> bool
Checks whether the given node ID is a member of this subnet.
Sourcepub fn get_node_key(&self, node_id: &Principal) -> Option<&[u8]>
pub fn get_node_key(&self, node_id: &Principal) -> Option<&[u8]>
Returns the public key of the given node ID, if it is a member of this subnet.
Sourcepub fn iter_nodes(&self) -> SubnetNodeIter<'_> ⓘ
pub fn iter_nodes(&self) -> SubnetNodeIter<'_> ⓘ
Returns an iterator over the nodes in this subnet.
Sourcepub fn iter_node_keys(&self) -> SubnetKeysIter<'_> ⓘ
pub fn iter_node_keys(&self) -> SubnetKeysIter<'_> ⓘ
Returns an iterator over the node IDs and their corresponding public keys in this subnet.
Sourcepub fn subnet_type(&self) -> Option<&SubnetType>
pub fn subnet_type(&self) -> Option<&SubnetType>
Returns the subnet type if it was present in the state tree certificate.
This is populated when the replica uses certification version V25 or higher.
Returns None for older certificates that do not include the type leaf.