mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 20:47:56 +00:00
sc-network: Log outgoing notifications too (#7624)
* Log outgoing notifications too * Update client/network/src/protocol/generic_proto/handler.rs Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: Addie Wagenknecht <addie@nortd.com> Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@@ -664,7 +664,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
|
||||
// `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, protocol.clone())) {
|
||||
if let Some(sink) = peers_notifications_sinks.get(&(target.clone(), protocol.clone())) {
|
||||
sink.clone()
|
||||
} else {
|
||||
// Notification silently discarded, as documented.
|
||||
@@ -684,6 +684,14 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -1139,6 +1147,7 @@ impl NotificationSender {
|
||||
Ok(r) => r,
|
||||
Err(()) => return Err(NotificationSenderError::Closed),
|
||||
},
|
||||
peer_id: self.sink.peer_id(),
|
||||
notification_size_metric: self.notification_size_metric.clone(),
|
||||
})
|
||||
}
|
||||
@@ -1149,6 +1158,9 @@ impl NotificationSender {
|
||||
pub struct NotificationSenderReady<'a> {
|
||||
ready: Ready<'a>,
|
||||
|
||||
/// Target of the notification.
|
||||
peer_id: &'a PeerId,
|
||||
|
||||
/// Field extracted from the [`Metrics`] struct and necessary to report the
|
||||
/// notifications-related metrics.
|
||||
notification_size_metric: Option<Histogram>,
|
||||
@@ -1163,6 +1175,15 @@ impl<'a> NotificationSenderReady<'a> {
|
||||
notification_size_metric.observe(notification.len() as f64);
|
||||
}
|
||||
|
||||
trace!(
|
||||
target: "sub-libp2p",
|
||||
"External API => Notification({:?}, {:?}, {} bytes)",
|
||||
self.peer_id,
|
||||
self.ready.protocol_name(),
|
||||
notification.len()
|
||||
);
|
||||
trace!(target: "sub-libp2p", "Handler({:?}) <= Async notification", self.peer_id);
|
||||
|
||||
self.ready
|
||||
.send(notification)
|
||||
.map_err(|()| NotificationSenderError::Closed)
|
||||
|
||||
Reference in New Issue
Block a user