hopr_transport_probe/
traits.rs

1use async_trait::async_trait;
2use hopr_network_types::types::DestinationRouting;
3use libp2p_identity::PeerId;
4
5#[cfg_attr(test, mockall::automock)]
6#[async_trait]
7pub trait PeerDiscoveryFetch {
8    /// Get untested peers not observed since a specific timestamp.
9    async fn get_peers(&self, from_timestamp: std::time::SystemTime) -> Vec<PeerId>;
10}
11
12#[async_trait]
13pub trait ProbeStatusUpdate {
14    /// Update the peer status after probing
15    async fn on_finished(&self, peer: &PeerId, result: &crate::errors::Result<std::time::Duration>);
16}
17
18/// A trait for types that can produce a stream of cover traffic routes.
19///
20/// The basic assumption is that the implementor will provide the logic
21/// to choose suitable route candidates for cover traffic based on a
22/// custom algorithm.
23///
24/// The implementor should ensure that the produced routes are indefinite,
25/// since the exhaustion of the stream might result in termination of the
26/// cover traffic generation.
27pub trait TrafficGeneration {
28    fn build(
29        self,
30    ) -> (
31        impl futures::Stream<Item = DestinationRouting> + Send,
32        impl futures::Sink<crate::errors::Result<crate::types::Telemetry>, Error = impl std::error::Error>
33        + Send
34        + Sync
35        + Clone
36        + 'static,
37    );
38}
39
40const _: () = assert!(size_of::<u128>() > crate::content::PathTelemetry::ID_SIZE);