pub struct HoprTransport<Chain, Graph, Net> {Show 13 fields
pub(crate) packet_key: OffchainKeypair,
pub(crate) chain_key: ChainKeypair,
pub(crate) chain_api: Chain,
pub(crate) ping: Arc<OnceLock<Pinger>>,
pub(crate) network: Arc<OnceLock<Net>>,
pub(crate) graph: Graph,
pub(crate) path_planner: PathPlanner<MemorySurbStore, Chain, HoprGraphPathSelector<Graph>>,
pub(crate) my_multiaddresses: Vec<Multiaddr>,
pub(crate) smgr: Arc<SessionManager<Sender<(DestinationRouting, ApplicationDataOut)>>>,
pub(crate) session_telemetry_tag_allocator: Arc<dyn TagAllocator + Send + Sync>,
pub(crate) probing_tag_allocator: Arc<dyn TagAllocator + Send + Sync>,
pub(crate) counters: PeerProtocolCounterRegistry,
pub(crate) cfg: HoprProtocolConfig,
}Expand description
Interface into the physical transport mechanism allowing all off-chain HOPR-related tasks on the transport.
Fields§
§packet_key: OffchainKeypair§chain_key: ChainKeypair§chain_api: Chain§ping: Arc<OnceLock<Pinger>>§network: Arc<OnceLock<Net>>§graph: Graph§path_planner: PathPlanner<MemorySurbStore, Chain, HoprGraphPathSelector<Graph>>§my_multiaddresses: Vec<Multiaddr>§smgr: Arc<SessionManager<Sender<(DestinationRouting, ApplicationDataOut)>>>§session_telemetry_tag_allocator: Arc<dyn TagAllocator + Send + Sync>§probing_tag_allocator: Arc<dyn TagAllocator + Send + Sync>§counters: PeerProtocolCounterRegistry§cfg: HoprProtocolConfigImplementations§
Source§impl<Chain, Graph, Net> HoprTransport<Chain, Graph, Net>where
Chain: ChainReadChannelOperations + ChainReadAccountOperations + ChainWriteTicketOperations + ChainKeyOperations + ChainReadTicketOperations + ChainValues + Clone + Send + Sync + 'static,
Graph: NetworkGraphView<NodeId = OffchainPublicKey> + NetworkGraphUpdate + NetworkGraphWrite<NodeId = OffchainPublicKey> + NetworkGraphTraverse<NodeId = OffchainPublicKey> + Clone + Send + Sync + 'static,
<Graph as NetworkGraphView>::Observed: EdgeObservableRead + Send,
<Graph as NetworkGraphTraverse>::Observed: EdgeObservableRead + Send + 'static,
<Graph as NetworkGraphWrite>::Observed: EdgeObservableWrite + Send,
Net: NetworkView + NetworkStreamControl + Clone + Send + Sync + 'static,
impl<Chain, Graph, Net> HoprTransport<Chain, Graph, Net>where
Chain: ChainReadChannelOperations + ChainReadAccountOperations + ChainWriteTicketOperations + ChainKeyOperations + ChainReadTicketOperations + ChainValues + Clone + Send + Sync + 'static,
Graph: NetworkGraphView<NodeId = OffchainPublicKey> + NetworkGraphUpdate + NetworkGraphWrite<NodeId = OffchainPublicKey> + NetworkGraphTraverse<NodeId = OffchainPublicKey> + Clone + Send + Sync + 'static,
<Graph as NetworkGraphView>::Observed: EdgeObservableRead + Send,
<Graph as NetworkGraphTraverse>::Observed: EdgeObservableRead + Send + 'static,
<Graph as NetworkGraphWrite>::Observed: EdgeObservableWrite + Send,
Net: NetworkView + NetworkStreamControl + Clone + Send + Sync + 'static,
pub fn new( identity: (&ChainKeypair, &OffchainKeypair), resolver: Chain, graph: Graph, my_multiaddresses: Vec<Multiaddr>, cfg: HoprProtocolConfig, ) -> Result<Self>
Sourcepub async fn run_relay<T, TFact, Ct>(
&self,
cover_traffic: Ct,
network: Net,
network_process: BoxedProcessFn,
ticket_events: T,
ticket_factory: TFact,
on_incoming_session: Sender<IncomingSession>,
) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
pub async fn run_relay<T, TFact, Ct>( &self, cover_traffic: Ct, network: Net, network_process: BoxedProcessFn, ticket_events: T, ticket_factory: TFact, on_incoming_session: Sender<IncomingSession>, ) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
Execute all processes of the HoprTransport object as a Relay node.
Relay nodes run the full packet pipeline including incoming ticket/acknowledgement
processing and require a [futures::Sink] for ticket events as well as an
on_incoming_session channel from the SessionManager (they can accept incoming sessions).
Sourcepub async fn run_exit<TFact, Ct>(
&self,
cover_traffic: Ct,
network: Net,
network_process: BoxedProcessFn,
ticket_factory: TFact,
on_incoming_session: Sender<IncomingSession>,
) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
pub async fn run_exit<TFact, Ct>( &self, cover_traffic: Ct, network: Net, network_process: BoxedProcessFn, ticket_factory: TFact, on_incoming_session: Sender<IncomingSession>, ) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
Execute all processes of the HoprTransport object as an Exit (destination) node.
Exit nodes do not process tickets but keep the incoming acknowledgement pipeline running and can accept incoming sessions via SessionManager.
Sourcepub async fn run_entry<TFact, Ct>(
&self,
cover_traffic: Ct,
network: Net,
network_process: BoxedProcessFn,
ticket_factory: TFact,
) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
pub async fn run_entry<TFact, Ct>( &self, cover_traffic: Ct, network: Net, network_process: BoxedProcessFn, ticket_factory: TFact, ) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
Execute all processes of the HoprTransport object as an Entry (source) node.
Entry nodes do not process tickets, do not start the incoming acknowledgement
pipeline, and do not accept incoming sessions — therefore, they require neither a
ticket_events sink nor an on_incoming_session channel.
Sourcepub(crate) async fn run_inner<T, TFact, Ct>(
&self,
role: NodeType,
cover_traffic: Ct,
network: Net,
network_process: BoxedProcessFn,
ticket_events: T,
ticket_factory: TFact,
on_incoming_session: Option<Sender<IncomingSession>>,
) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
pub(crate) async fn run_inner<T, TFact, Ct>( &self, role: NodeType, cover_traffic: Ct, network: Net, network_process: BoxedProcessFn, ticket_events: T, ticket_factory: TFact, on_incoming_session: Option<Sender<IncomingSession>>, ) -> Result<(HoprSocket<BoxStream<'static, ApplicationDataIn>, Sender<(DestinationRouting, ApplicationDataOut)>>, AbortableList<HoprTransportProcess>)>
Internal worker driving all node-type variants of HoprTransport::run_*.
Branches on role:
protocol::NodeType::Relay: full packet pipeline + SessionManager.protocol::NodeType::Exit: ack-drain pipeline + incoming Sessions.protocol::NodeType::Entry: no ack pipeline, no incoming Sessions.
pub async fn ping( &self, peer: &OffchainPublicKey, ) -> Result<(Duration, <Graph as NetworkGraphView>::Observed)>
pub async fn new_session( &self, destination: Address, target: SessionTarget, cfg: SessionClientConfig, ) -> Result<(HoprSession, HoprSessionConfigurator)>
pub async fn listening_multiaddresses(&self) -> Vec<Multiaddr>
pub fn announceable_multiaddresses(&self) -> Vec<Multiaddr>
pub fn local_multiaddresses(&self) -> Vec<Multiaddr>
pub async fn network_observed_multiaddresses( &self, peer: &OffchainPublicKey, ) -> Vec<Multiaddr>
pub async fn network_health(&self) -> Health
pub async fn network_connected_peers(&self) -> Result<Vec<OffchainPublicKey>>
pub fn network_peer_observations( &self, peer: &OffchainPublicKey, ) -> Option<<Graph as NetworkGraphView>::Observed>
Sourcepub async fn all_network_peers(
&self,
minimum_score: f64,
) -> Result<Vec<(OffchainPublicKey, <Graph as NetworkGraphView>::Observed)>>
pub async fn all_network_peers( &self, minimum_score: f64, ) -> Result<Vec<(OffchainPublicKey, <Graph as NetworkGraphView>::Observed)>>
Get connected peers with quality higher than some value.
Trait Implementations§
Source§impl<Chain, Graph, Net> NetworkView for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> NetworkView for HoprTransport<Chain, Graph, Net>
Source§fn listening_as(&self) -> HashSet<Multiaddr>
fn listening_as(&self) -> HashSet<Multiaddr>
Source§fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>
fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>
Source§fn discovered_peers(&self) -> HashSet<PeerId>
fn discovered_peers(&self) -> HashSet<PeerId>
Source§fn connected_peers(&self) -> HashSet<PeerId>
fn connected_peers(&self) -> HashSet<PeerId>
Source§fn is_connected(&self, peer: &PeerId) -> bool
fn is_connected(&self, peer: &PeerId) -> bool
Source§fn subscribe_network_events(
&self,
) -> impl Stream<Item = NetworkEvent> + Send + 'static
fn subscribe_network_events( &self, ) -> impl Stream<Item = NetworkEvent> + Send + 'static
Source§impl<Chain, Graph, Net> TransportOperations for HoprTransport<Chain, Graph, Net>where
Chain: ChainReadChannelOperations + ChainReadAccountOperations + ChainWriteTicketOperations + ChainKeyOperations + ChainReadTicketOperations + ChainValues + Clone + Send + Sync + 'static,
Graph: NetworkGraphView<NodeId = OffchainPublicKey> + NetworkGraphUpdate + NetworkGraphWrite<NodeId = OffchainPublicKey> + NetworkGraphTraverse<NodeId = OffchainPublicKey> + Clone + Send + Sync + 'static,
<Graph as NetworkGraphView>::Observed: EdgeObservableRead + Send,
<Graph as NetworkGraphTraverse>::Observed: EdgeObservableRead + Send + 'static,
<Graph as NetworkGraphWrite>::Observed: EdgeObservableWrite + Send,
Net: NetworkView + NetworkStreamControl + Clone + Send + Sync + 'static,
impl<Chain, Graph, Net> TransportOperations for HoprTransport<Chain, Graph, Net>where
Chain: ChainReadChannelOperations + ChainReadAccountOperations + ChainWriteTicketOperations + ChainKeyOperations + ChainReadTicketOperations + ChainValues + Clone + Send + Sync + 'static,
Graph: NetworkGraphView<NodeId = OffchainPublicKey> + NetworkGraphUpdate + NetworkGraphWrite<NodeId = OffchainPublicKey> + NetworkGraphTraverse<NodeId = OffchainPublicKey> + Clone + Send + Sync + 'static,
<Graph as NetworkGraphView>::Observed: EdgeObservableRead + Send,
<Graph as NetworkGraphTraverse>::Observed: EdgeObservableRead + Send + 'static,
<Graph as NetworkGraphWrite>::Observed: EdgeObservableWrite + Send,
Net: NetworkView + NetworkStreamControl + Clone + Send + Sync + 'static,
Source§type Error = HoprTransportError
type Error = HoprTransportError
Source§type Observable = <Graph as NetworkGraphView>::Observed
type Observable = <Graph as NetworkGraphView>::Observed
Source§fn ping<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Result<(Duration, Self::Observable), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ping<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Result<(Duration, Self::Observable), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn observed_multiaddresses<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Vec<Multiaddr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn observed_multiaddresses<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 OffchainPublicKey,
) -> Pin<Box<dyn Future<Output = Vec<Multiaddr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl<Chain, Graph, Net> Freeze for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> !RefUnwindSafe for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> Send for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> Sync for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> Unpin for HoprTransport<Chain, Graph, Net>
impl<Chain, Graph, Net> !UnwindSafe for HoprTransport<Chain, Graph, Net>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.