Struct network::transport::AptosNetTransport
source · [−]pub struct AptosNetTransport<TTransport> { /* private fields */ }Expand description
The common AptosNet 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
sourceimpl<TTransport> AptosNetTransport<TTransport> where
TTransport: Transport<Error = Error>,
TTransport::Output: TSocket,
TTransport::Outbound: Send + 'static,
TTransport::Inbound: Send + 'static,
TTransport::Listener: Send + 'static,
impl<TTransport> AptosNetTransport<TTransport> where
TTransport: Transport<Error = Error>,
TTransport::Output: TSocket,
TTransport::Outbound: Send + 'static,
TTransport::Inbound: Send + 'static,
TTransport::Listener: Send + 'static,
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
sourcepub 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> + /noise-ik/<pubkey>/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>
sourcepub 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
sourceimpl<TTransport: Transport> Transport for AptosNetTransport<TTransport> where
TTransport: Transport<Error = Error> + Send + 'static,
TTransport::Output: TSocket,
TTransport::Outbound: Send + 'static,
TTransport::Inbound: Send + 'static,
TTransport::Listener: Send + 'static,
impl<TTransport: Transport> Transport for AptosNetTransport<TTransport> where
TTransport: Transport<Error = Error> + Send + 'static,
TTransport::Output: TSocket,
TTransport::Outbound: Send + 'static,
TTransport::Inbound: Send + 'static,
TTransport::Listener: Send + 'static,
type Output = Connection<NoiseStream<<TTransport as Transport>::Output>>
type Output = Connection<NoiseStream<<TTransport as Transport>::Output>>
The result of establishing a connection. Read more
type Inbound = Pin<Box<dyn Future<Output = Result<<AptosNetTransport<TTransport> as Transport>::Output, Error>> + Send + 'static, Global>>
type Inbound = Pin<Box<dyn Future<Output = Result<<AptosNetTransport<TTransport> as Transport>::Output, Error>> + Send + 'static, Global>>
type Outbound = Pin<Box<dyn Future<Output = Result<<AptosNetTransport<TTransport> as Transport>::Output, Error>> + Send + 'static, Global>>
type Outbound = Pin<Box<dyn Future<Output = Result<<AptosNetTransport<TTransport> as Transport>::Output, Error>> + Send + 'static, Global>>
type Listener = Pin<Box<dyn Stream<Item = Result<(<AptosNetTransport<TTransport> as Transport>::Inbound, NetworkAddress), Error>> + Send + 'static, Global>>
type Listener = Pin<Box<dyn Stream<Item = Result<(<AptosNetTransport<TTransport> as Transport>::Inbound, NetworkAddress), Error>> + Send + 'static, Global>>
sourcefn dial(&self, peer_id: PeerId, addr: NetworkAddress) -> Result<Self::Outbound>
fn dial(&self, peer_id: PeerId, addr: NetworkAddress) -> Result<Self::Outbound>
Dials the given NetworkAddress, returning a future for a pending outbound connection.
sourcefn listen_on(
&self,
addr: NetworkAddress
) -> Result<(Self::Listener, NetworkAddress)>
fn listen_on(
&self,
addr: NetworkAddress
) -> Result<(Self::Listener, NetworkAddress)>
Listens on the given NetworkAddress, returning a stream of incoming connections. Read more
Auto Trait Implementations
impl<TTransport> RefUnwindSafe for AptosNetTransport<TTransport> where
TTransport: RefUnwindSafe,
impl<TTransport> Send for AptosNetTransport<TTransport> where
TTransport: Send,
impl<TTransport> Sync for AptosNetTransport<TTransport> where
TTransport: Sync,
impl<TTransport> Unpin for AptosNetTransport<TTransport> where
TTransport: Unpin,
impl<TTransport> UnwindSafe for AptosNetTransport<TTransport> where
TTransport: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> TransportExt for T where
T: Transport + ?Sized,
impl<T> TransportExt for T where
T: Transport + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more