hopr_transport_probe/
types.rs1use hopr_crypto_random::Randomizable;
2use hopr_internal_types::{NodeId, protocol::HoprPseudonym};
3use hopr_network_types::types::{DestinationRouting, RoutingOptions};
4use hopr_primitive_types::bounded::BoundedVec;
5
6use crate::content::PathTelemetry;
7
8pub struct TaggedDestinationRouting {
9 pub destination: Box<NodeId>,
11 pub pseudonym: HoprPseudonym,
13 pub forward_options: RoutingOptions,
15 pub return_options: Option<RoutingOptions>,
17}
18
19impl TaggedDestinationRouting {
20 pub fn neighbor(destination: Box<NodeId>) -> Self {
21 Self {
22 destination,
23 pseudonym: HoprPseudonym::random(),
24 forward_options: RoutingOptions::Hops(0.try_into().expect("0 is a valid u8")),
25 return_options: Some(RoutingOptions::Hops(0.try_into().expect("0 is a valid u8"))),
26 }
27 }
28
29 pub fn loopback(me: Box<NodeId>, path: BoundedVec<NodeId, { RoutingOptions::MAX_INTERMEDIATE_HOPS }>) -> Self {
30 Self {
31 destination: me,
32 pseudonym: HoprPseudonym::random(),
33 forward_options: RoutingOptions::IntermediatePath(path),
34 return_options: None,
35 }
36 }
37}
38
39impl From<TaggedDestinationRouting> for DestinationRouting {
40 fn from(value: TaggedDestinationRouting) -> Self {
41 DestinationRouting::Forward {
42 destination: value.destination,
43 pseudonym: Some(value.pseudonym),
44 forward_options: value.forward_options,
45 return_options: value.return_options,
46 }
47 }
48}
49
50pub struct NeighborTelemetry {
51 pub peer: libp2p_identity::PeerId,
52 pub rtt: std::time::Duration,
53}
54
55pub enum Telemetry {
56 Loopback(PathTelemetry),
57 Neighbor(NeighborTelemetry),
58}