hopr_api/ct/
types.rs

1use multiaddr::PeerId;
2
3#[derive(thiserror::Error, Debug)]
4pub enum TrafficGenerationError<P>
5where
6    P: MeasurablePath,
7{
8    #[error("timed out for near neighbor probe '{0:?}'")]
9    ProbeNeighborTimeout(PeerId),
10
11    #[error("timed out for loopback probe")]
12    ProbeLoopbackTimeout(P),
13}
14
15/// Measurable neighbor telemetry.
16pub trait MeasurableNeighbor {
17    fn peer(&self) -> &PeerId;
18    fn rtt(&self) -> std::time::Duration;
19}
20
21/// Measurable path telemetry.
22pub trait MeasurablePath {
23    fn id(&self) -> &[u8];
24    fn path(&self) -> &[u8];
25    fn timestamp(&self) -> u128;
26}
27
28/// Enum representing different types of telemetry data used by the CT mechanism.
29#[derive(Debug, Clone)]
30pub enum Telemetry<N, P>
31where
32    N: MeasurableNeighbor + Clone,
33    P: MeasurablePath + Clone,
34{
35    /// Telemetry data looping the traffic through multiple peers back to self.
36    ///
37    /// Does not require a cooperating peer.
38    Loopback(P),
39    /// Immediate neighbor telemetry data.
40    ///
41    /// Assumes a cooperating immediate peer to receive responses for telemetry construction
42    Neighbor(N),
43}