diff --git a/crypto/src/typestate.rs b/crypto/src/typestate.rs index d38cb865b..0e7ca04cb 100644 --- a/crypto/src/typestate.rs +++ b/crypto/src/typestate.rs @@ -102,12 +102,12 @@ where impl Valid { #[inline(always)] - pub fn unwrap(self) -> T { + pub fn remove_typestate(self) -> T { self.0 } #[inline(always)] - pub fn wrap(o: T) -> Self { + pub fn mark_valid(o: T) -> Self { Self(o) } } @@ -212,12 +212,12 @@ where impl Verified { #[inline(always)] - pub fn unwrap(self) -> T { + pub fn remove_typestate(self) -> T { self.0 } #[inline(always)] - pub fn wrap(o: T) -> Self { + pub fn mark_verified(o: T) -> Self { Self(o) } } diff --git a/network-hypervisor/src/vl1/identity.rs b/network-hypervisor/src/vl1/identity.rs index 8046139bd..ac3793ce5 100644 --- a/network-hypervisor/src/vl1/identity.rs +++ b/network-hypervisor/src/vl1/identity.rs @@ -206,7 +206,7 @@ impl Identity { assert!(id.upgrade().is_ok()); assert!(id.p384.is_some() && id.secret.as_ref().unwrap().p384.is_some()); - Valid::wrap(id) + Valid::mark_valid(id) } /// Upgrade older x25519-only identities to hybrid identities with both x25519 and NIST P-384 curves. @@ -321,7 +321,7 @@ impl Identity { zt_address_derivation_work_function(&mut digest); return if digest[0] < IDENTITY_POW_THRESHOLD && Address::from_bytes(&digest[59..64]).map_or(false, |a| a == self.address) { - Some(Valid::wrap(self)) + Some(Valid::mark_valid(self)) } else { None }; diff --git a/network-hypervisor/src/vl1/node.rs b/network-hypervisor/src/vl1/node.rs index 0efd77d97..98a63bf89 100644 --- a/network-hypervisor/src/vl1/node.rs +++ b/network-hypervisor/src/vl1/node.rs @@ -298,7 +298,7 @@ impl Node { let old = id.clone(); if id.upgrade()? { app.save_node_identity(&id); - app.event(Event::IdentityAutoUpgraded(old.unwrap(), id.as_ref().clone())); + app.event(Event::IdentityAutoUpgraded(old.remove_typestate(), id.as_ref().clone())); } } @@ -388,7 +388,14 @@ impl Node { /// Get the root sets that this node trusts. #[inline] pub fn root_sets(&self) -> Vec { - self.roots.read().unwrap().sets.values().cloned().map(|s| s.unwrap()).collect() + self.roots + .read() + .unwrap() + .sets + .values() + .cloned() + .map(|s| s.remove_typestate()) + .collect() } pub fn do_background_tasks(&self, app: &Application) -> Duration { @@ -468,7 +475,7 @@ impl Node { if let Some(peer) = peers.get(&m.identity.address) { new_roots.insert(peer.clone(), m.endpoints.as_ref().unwrap().iter().cloned().collect()); } else { - if let Some(peer) = Peer::new(&self.identity, Valid::wrap(m.identity.clone()), time_ticks) { + if let Some(peer) = Peer::new(&self.identity, Valid::mark_valid(m.identity.clone()), time_ticks) { drop(peers); new_roots.insert( self.peers diff --git a/network-hypervisor/src/vl1/rootset.rs b/network-hypervisor/src/vl1/rootset.rs index 36de52519..8418660f5 100644 --- a/network-hypervisor/src/vl1/rootset.rs +++ b/network-hypervisor/src/vl1/rootset.rs @@ -119,7 +119,7 @@ impl RootSet { } } - return Some(Verified::wrap(self)); + return Some(Verified::mark_verified(self)); } /// Add a member to this definition, replacing any current entry with this address. diff --git a/network-hypervisor/src/vl2/v1/certificateofmembership.rs b/network-hypervisor/src/vl2/v1/certificateofmembership.rs index bd605ab1e..5cad32d97 100644 --- a/network-hypervisor/src/vl2/v1/certificateofmembership.rs +++ b/network-hypervisor/src/vl2/v1/certificateofmembership.rs @@ -177,7 +177,7 @@ impl CertificateOfMembership { &self.issued_to_fingerprint.as_bytes()[..32], ) { if issuer.verify(&self.v1_proto_get_qualifier_bytes(), self.signature.as_bytes()) { - return Some(Verified::wrap(self)); + return Some(Verified::mark_verified(self)); } } return None; diff --git a/service/src/utils.rs b/service/src/utils.rs index 832b21fbc..074e7b81f 100644 --- a/service/src/utils.rs +++ b/service/src/utils.rs @@ -45,7 +45,7 @@ pub fn parse_cli_identity(input: &str, validate: bool) -> Result Option> { if id_data.is_err() { return None; } - Some(Valid::wrap(id_data.unwrap())) + Some(Valid::mark_valid(id_data.unwrap())) } pub fn save_node_identity(base_path: &Path, id: &Valid) -> bool {