From 4cdece6d0f8e25ac154c3fd0f30bca604b08c16a Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Oct 2026 01:31:58 +0100 Subject: add identity layer --- src/transport/traffic.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/transport/traffic.rs') diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs index c27f0d7..59acaf2 100644 --- a/src/transport/traffic.rs +++ b/src/transport/traffic.rs @@ -40,6 +40,9 @@ pub(crate) struct ByKind { pub(crate) ping: Counter, pub(crate) pong: Counter, pub(crate) blob: Counter, + /// WHO and ME (`transport::identity`), counted by the identity layer under the + /// address they went to or came from. + pub(crate) identity: Counter, } impl ByKind { @@ -51,6 +54,7 @@ impl ByKind { MessageKind::Ping => &mut self.ping, MessageKind::Pong => &mut self.pong, MessageKind::Blob => &mut self.blob, + MessageKind::Who | MessageKind::Me => &mut self.identity, } } } @@ -92,15 +96,15 @@ impl Traffic { } } - fn sent(&self, peer: &str, kind: MessageKind, bytes: usize) { + pub(crate) fn sent(&self, peer: &str, kind: MessageKind, bytes: usize) { self.count(peer, bytes, |t| t.sent.get_mut(kind)); } - fn refused(&self, peer: &str, kind: MessageKind, bytes: usize) { + pub(crate) fn refused(&self, peer: &str, kind: MessageKind, bytes: usize) { self.count(peer, bytes, |t| t.refused.get_mut(kind)); } - fn received(&self, peer: &str, kind: MessageKind, bytes: usize) { + pub(crate) fn received(&self, peer: &str, kind: MessageKind, bytes: usize) { self.count(peer, bytes, |t| t.received.get_mut(kind)); } -- cgit v1.3.1