pub struct NetworkSender<TMessage> { /* private fields */ }Expand description
NetworkSender is the generic interface from upper network applications to
the lower network layer. It provides the full API for network applications,
including sending direct-send messages, sending rpc requests, as well as
dialing or disconnecting from peers and updating the list of accepted public
keys.
NetworkSender is in fact a thin wrapper around a PeerManagerRequestSender, which in turn is
a thin wrapper on aptos_channel::Sender<(PeerId, ProtocolId), PeerManagerRequest>,
mostly focused on providing a more ergonomic API. However, network applications will usually
provide their own thin wrapper around NetworkSender that narrows the API to the specific
interface they need. For instance, mempool only requires direct-send functionality so its
MempoolNetworkSender only exposes a send_to function.
Provide Protobuf wrapper over [peer_manager::PeerManagerRequestSender]
Implementations
sourceimpl<TMessage> NetworkSender<TMessage>
impl<TMessage> NetworkSender<TMessage>
sourcepub async fn dial_peer(
&self,
peer: PeerId,
addr: NetworkAddress
) -> Result<(), NetworkError>
pub async fn dial_peer(
&self,
peer: PeerId,
addr: NetworkAddress
) -> Result<(), NetworkError>
Request that a given Peer be dialed at the provided NetworkAddress and
synchronously wait for the request to be performed.
sourcepub async fn disconnect_peer(&self, peer: PeerId) -> Result<(), NetworkError>
pub async fn disconnect_peer(&self, peer: PeerId) -> Result<(), NetworkError>
Request that a given Peer be disconnected and synchronously wait for the request to be performed.
sourceimpl<TMessage: Message> NetworkSender<TMessage>
impl<TMessage: Message> NetworkSender<TMessage>
sourcepub fn send_to(
&self,
recipient: PeerId,
protocol: ProtocolId,
message: TMessage
) -> Result<(), NetworkError>
pub fn send_to(
&self,
recipient: PeerId,
protocol: ProtocolId,
message: TMessage
) -> Result<(), NetworkError>
Send a protobuf message to a single recipient. Provides a wrapper over
[peer_manager::PeerManagerRequestSender::send_to].
sourcepub fn send_to_many(
&self,
recipients: impl Iterator<Item = PeerId>,
protocol: ProtocolId,
message: TMessage
) -> Result<(), NetworkError>
pub fn send_to_many(
&self,
recipients: impl Iterator<Item = PeerId>,
protocol: ProtocolId,
message: TMessage
) -> Result<(), NetworkError>
Send a protobuf message to a many recipients. Provides a wrapper over
[peer_manager::PeerManagerRequestSender::send_to_many].
sourcepub async fn send_rpc(
&self,
recipient: PeerId,
protocol: ProtocolId,
req_msg: TMessage,
timeout: Duration
) -> Result<TMessage, RpcError>
pub async fn send_rpc(
&self,
recipient: PeerId,
protocol: ProtocolId,
req_msg: TMessage,
timeout: Duration
) -> Result<TMessage, RpcError>
Send a protobuf rpc request to a single recipient while handling serialization and deserialization of the request and response respectively. Assumes that the request and response both have the same message type.
Trait Implementations
sourceimpl<TMessage: Clone> Clone for NetworkSender<TMessage>
impl<TMessage: Clone> Clone for NetworkSender<TMessage>
sourcefn clone(&self) -> NetworkSender<TMessage>
fn clone(&self) -> NetworkSender<TMessage>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<TMessage: Debug> Debug for NetworkSender<TMessage>
impl<TMessage: Debug> Debug for NetworkSender<TMessage>
sourceimpl<TMessage> NewNetworkSender for NetworkSender<TMessage>
impl<TMessage> NewNetworkSender for NetworkSender<TMessage>
fn new(
peer_mgr_reqs_tx: PeerManagerRequestSender,
connection_reqs_tx: ConnectionRequestSender
) -> Self
Auto Trait Implementations
impl<TMessage> RefUnwindSafe for NetworkSender<TMessage> where
TMessage: RefUnwindSafe,
impl<TMessage> Send for NetworkSender<TMessage> where
TMessage: Send,
impl<TMessage> Sync for NetworkSender<TMessage> where
TMessage: Sync,
impl<TMessage> Unpin for NetworkSender<TMessage> where
TMessage: Unpin,
impl<TMessage> UnwindSafe for NetworkSender<TMessage> where
TMessage: 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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
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