pub fn write_notification(&self, target: PeerId, protocol: Cow<'static, str>, message: Vec<u8>) {
		// We clone the `NotificationsSink` in order to be able to unlock the network-wide
		// `peers_notifications_sinks` mutex as soon as possible.
		let sink = {
			let peers_notifications_sinks = self.peers_notifications_sinks.lock();
			if let Some(sink) = peers_notifications_sinks.get(&(target.clone(), protocol.clone())) {
				sink.clone()
			} else {
				// Notification silently discarded, as documented.
				log::debug!(
					target: "sub-libp2p",
					"Attempted to send notification on missing or closed substream: {:?}",
					protocol,
				);
				return;
			}
		};

		if let Some(notifications_sizes_metric) = self.notifications_sizes_metric.as_ref() {
			notifications_sizes_metric
				.with_label_values(&["out", &protocol])
				.observe(message.len() as f64);
		}

		// Sending is communicated to the `NotificationsSink`.
		trace!(
			target: "sub-libp2p",
			"External API => Notification({:?}, {:?}, {} bytes)",
			target,
			protocol,
			message.len()
		);
		trace!(target: "sub-libp2p", "Handler({:?}) <= Sync notification", target);
		sink.send_sync_notification(protocol, message);
	}
/// Appends a notification to the buffer of pending outgoing notifications with the given peer.
/// Has no effect if the notifications channel with this protocol name is not open.
///
/// If the buffer of pending outgoing notifications with that peer is full, the notification
/// is silently dropped and the connection to the remote will start being shut down. This
/// happens if you call this method at a higher rate than the rate at which the peer processes
/// these notifications, or if the available network bandwidth is too low.
///
/// For this reason, this method is considered soft-deprecated. You are encouraged to use
/// [`NetworkService::notification_sender`] instead.
///
/// > **Note**: The reason why this is a no-op in the situation where we have no channel is
/// >			that we don't guarantee message delivery anyway. Networking issues can cause
/// >			connections to drop at any time, and higher-level logic shouldn't differentiate
/// >			between the remote voluntarily closing a substream or a network error
/// >			preventing the message from being delivered.
///
/// The protocol must have been registered with
/// [`NetworkConfiguration::notifications_protocols`](crate::config::NetworkConfiguration::notifications_protocols).
///
Appends a notification to the buffer of pending outgoing notifications with the given peer.
Has no effect if the notifications channel with this protocol name is not open.

If the buffer of pending outgoing notifications with that peer is full, the notification
is silently dropped and the connection to the remote will start being shut down. This
happens if you call this method at a higher rate than the rate at which the peer processes
these notifications, or if the available network bandwidth is too low.

For this reason, this method is considered soft-deprecated. You are encouraged to use
[`NetworkService::notification_sender`] instead.

> **Note**: The reason why this is a no-op in the situation where we have no channel is
>                      that we don't guarantee message delivery anyway. Networking issues can cause
>                      connections to drop at any time, and higher-level logic shouldn't differentiate
>                      between the remote voluntarily closing a substream or a network error
>                      preventing the message from being delivered.


Appends a notification to the buffer of pending outgoing notifications with the given peer . Has no effect if the notifications channel with this protocol name is not open . If the buffer of pending outgoing notifications with that peer is full the notification is silently dropped and the connection to the remote will start being shut down . This happens if you call this method at a higher rate than the rate at which the peer processes these notifications or if the available network bandwidth is too low . For this reason this method is considered soft - deprecated . You are encouraged to use [ ` NetworkService :: notification_sender ` ] instead . > ** Note ** : The reason why this is a no - op in the situation where we have no channel is > that we don ' t guarantee message delivery anyway . Networking issues can cause > connections to drop at any time and higher - level logic shouldn ' t differentiate > between the remote voluntarily closing a substream or a network error > preventing the message from being delivered .
pub fn write_notification(&self, target: PeerId, protocol: Cow<'static, str>, message: Vec<u8>) {
		// We clone the `NotificationsSink` in order to be able to unlock the network-wide
		// `peers_notifications_sinks` mutex as soon as possible.
		let sink = {
			let peers_notifications_sinks = self.peers_notifications_sinks.lock();
			if let Some(sink) = peers_notifications_sinks.get(&(target.clone(), protocol.clone())) {
				sink.clone()
			} else {
				// Notification silently discarded, as documented.
				log::debug!(
					target: "sub-libp2p",
					"Attempted to send notification on missing or closed substream: {:?}",
					protocol,
				);
				return;
			}
		};
		if let Some(notifications_sizes_metric) = self.notifications_sizes_metric.as_ref() {
			notifications_sizes_metric
				.with_label_values(&["out", &protocol])
				.observe(message.len() as f64);
		}
		// Sending is communicated to the `NotificationsSink`.
		trace!(
			target: "sub-libp2p",
			"External API => Notification({:?}, {:?}, {} bytes)",
			target,
			protocol,
			message.len()
		);
		trace!(target: "sub-libp2p", "Handler({:?}) <= Sync notification", target);
		sink.send_sync_notification(protocol, message);
	}
pub fn write_notification ( & self , target : PeerId , protocol : Cow < ' static , str > , message : Vec < u8 > ) { // We clone the `NotificationsSink` in order to be able to unlock the network-wide // `peers_notifications_sinks` mutex as soon as possible. let sink = { let peers_notifications_sinks = self . peers_notifications_sinks . lock ( ) ; if let Some ( sink ) = peers_notifications_sinks . get ( & ( target . clone ( ) , protocol . clone ( ) ) ) { sink . clone ( ) } else { // Notification silently discarded, as documented. log :: debug ! ( target " " " " protocol ) ; return ; } } ; if let Some ( notifications_sizes_metric ) = self . notifications_sizes_metric . as_ref ( ) { notifications_sizes_metric . with_label_values ( & [ " " , & protocol ] ) . observe ( message . len ( ) as f64 ) ; } // Sending is communicated to the `NotificationsSink`. trace ! ( target " " " " target protocol message len ( ) ) ; trace ! ( target " " " " target ) ; sink . send_sync_notification ( protocol , message ) ; }
Appends a notification to the buffer of pending outgoing notifications with the given peer.
Appends a notification to the buffer of pending outgoing notifications with the given peer .
&self
target
PeerId
protocol
Cow<'static, str>
message
Vec<u8>
&self
target
PeerId
protocol
Cow<'static, str>
message
Vec<u8>