checkpoint

This commit is contained in:
John Smith
2022-10-20 15:09:04 -04:00
parent 6d5df71ac1
commit fc6eb6e84a
3 changed files with 119 additions and 60 deletions

View File

@@ -48,6 +48,19 @@ impl PrivateRoute {
first_hop: None,
}
}
pub fn simplify(self) -> Self {
Self {
public_key: self.public_key,
hop_count: self.hop_count,
first_hop: self.first_hop.map(|h| RouteHop {
node: match h.node {
RouteNode::NodeId(ni) => RouteNode::NodeId(ni),
RouteNode::PeerInfo(pi) => RouteNode::NodeId(pi.node_id),
},
next_hop: h.next_hop,
}),
}
}
}
impl fmt::Display for PrivateRoute {
@@ -79,6 +92,16 @@ pub struct SafetyRoute {
pub hops: SafetyRouteHops,
}
impl SafetyRoute {
pub fn new_stub(public_key: DHTKey, private_route: PrivateRoute) -> Self {
Self {
public_key,
hop_count: 0,
hops: SafetyRouteHops::Private(private_route),
}
}
}
impl fmt::Display for SafetyRoute {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(