checkpoint

This commit is contained in:
John Smith
2022-11-22 22:48:03 -05:00
parent e4406cb022
commit d7e7f3ba1d
4 changed files with 123 additions and 25 deletions

View File

@@ -83,6 +83,14 @@ impl PrivateRoute {
}
}
/// Check if this is a stub route
pub fn is_stub(&self) -> bool {
if let PrivateRouteHops::FirstHop(first_hop) = self.hops {
return first_hop.next_hop.is_none();
}
false
}
/// Remove the first unencrypted hop if possible
pub fn pop_first_hop(&mut self) -> Option<RouteNode> {
match &mut self.hops {
@@ -149,6 +157,8 @@ pub struct SafetyRoute {
impl SafetyRoute {
pub fn new_stub(public_key: DHTKey, private_route: PrivateRoute) -> Self {
// First hop should have already been popped off for stubbed safety routes since
// we are sending directly to the first hop
assert!(matches!(private_route.hops, PrivateRouteHops::Data(_)));
Self {
public_key,
@@ -156,6 +166,9 @@ impl SafetyRoute {
hops: SafetyRouteHops::Private(private_route),
}
}
pub fn is_stub(&self) -> bool {
matches!(self.hops, SafetyRouteHops::Private(_))
}
}
impl fmt::Display for SafetyRoute {