Struct network::transport::DiemNetTransport [−][src]
pub struct DiemNetTransport<TTransport> { /* fields omitted */ }Expand description
The common DiemNet Transport.
The base transport layer is pluggable, so long as it provides a reliable,
ordered, connection-oriented, byte-stream abstraction (e.g., TCP). We currently
use either MemoryTransport or TcpTransport as this base layer.
Inbound and outbound connections are first established with the base_transport
and then negotiate a secure, authenticated transport layer (currently Noise
protocol). Finally, we negotiate common supported application protocols with
the Handshake protocol.
Implementations
pub fn new(
base_transport: TTransport,
network_context: NetworkContext,
time_service: TimeService,
identity_key: PrivateKey,
auth_mode: HandshakeAuthMode,
handshake_version: u8,
chain_id: ChainId,
application_protocols: ProtocolIdSet,
enable_proxy_protocol: bool
) -> Self
pub fn dial(
&self,
peer_id: PeerId,
addr: NetworkAddress
) -> Result<impl Future<Output = Result<Connection<NoiseStream<TTransport::Output>>>> + Send + 'static>
pub fn dial(
&self,
peer_id: PeerId,
addr: NetworkAddress
) -> Result<impl Future<Output = Result<Connection<NoiseStream<TTransport::Output>>>> + Send + 'static>
Dial a peer at addr. If the addr is not supported or formatted correctly,
return Err. Otherwise, return a Future that resolves to Err if there
was some issue dialing the peer and Ok with a fully upgraded connection
to that peer if our dial was successful.
Dialing NetworkAddress format
We parse the dial address like:
/<base_transport> + /ln-noise-ik/<pubkey>/ln-handshake/<version>
If the base transport is MemoryTransport, then /<base_transport> is:
/memory/<port>
If the base transport is TcpTransport, then /<base_transport> is:
/ip4/<ipaddr>/tcp/<port> or
/ip6/<ipaddr>/tcp/<port> or
/dns/<ipaddr>/tcp/<port> or
/dns4/<ipaddr>/tcp/<port> or
/dns6/<ipaddr>/tcp/<port>
pub fn listen_on(
&self,
addr: NetworkAddress
) -> Result<(impl Stream<Item = Result<(impl Future<Output = Result<Connection<NoiseStream<TTransport::Output>>>> + Send + 'static, NetworkAddress)>> + Send + 'static, NetworkAddress)>
pub fn listen_on(
&self,
addr: NetworkAddress
) -> Result<(impl Stream<Item = Result<(impl Future<Output = Result<Connection<NoiseStream<TTransport::Output>>>> + Send + 'static, NetworkAddress)>> + Send + 'static, NetworkAddress)>
Listen on address addr. If the addr is not supported or formatted correctly,
return Err. Otherwise, return a Stream of fully upgraded inbound connections
and the dialer’s observed network address.
Listening NetworkAddress format
When listening, we only expect the base transport format. For example,
if the base transport is MemoryTransport, then we expect:
/memory/<port>
If the base transport is TcpTransport, then we expect:
/ip4/<ipaddr>/tcp/<port> or
/ip6/<ipaddr>/tcp/<port>
Trait Implementations
type Output = Connection<NoiseStream<TTransport::Output>>
type Output = Connection<NoiseStream<TTransport::Output>>
The result of establishing a connection. Read more
Dials the given NetworkAddress, returning a future for a pending outbound connection.
Listens on the given NetworkAddress, returning a stream of incoming connections. Read more
Auto Trait Implementations
impl<TTransport> RefUnwindSafe for DiemNetTransport<TTransport> where
TTransport: RefUnwindSafe,
impl<TTransport> Send for DiemNetTransport<TTransport> where
TTransport: Send,
impl<TTransport> Sync for DiemNetTransport<TTransport> where
TTransport: Sync,
impl<TTransport> Unpin for DiemNetTransport<TTransport> where
TTransport: Unpin,
impl<TTransport> UnwindSafe for DiemNetTransport<TTransport> where
TTransport: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self
Turns a Transport into an abstract boxed transport.