checkpoint
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user