aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/stats.rs')
-rw-r--r--src/swarm/stats.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index 6332901..31b6a3b 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -137,6 +137,11 @@ pub(crate) struct Relay {
pub(crate) deflated: u64,
pub(crate) deflated_from: u64,
pub(crate) deflated_to: u64,
+ /// Blob chunks served, those of them deflated, and their bytes before and as sent.
+ pub(crate) chunks_served: u64,
+ pub(crate) chunks_deflated: u64,
+ pub(crate) chunk_bytes: u64,
+ pub(crate) chunk_bytes_sent: u64,
/// Sync messages received that carried changes, all of which we had already, and
/// their payload's bytes: changes that came twice. Of those, how many came along a
/// writer's tree (`SyncEnvelope::writer`), and how many were taken as delivered by
@@ -258,6 +263,15 @@ impl NodeStats {
self.lock().relay.tree_forwards += 1;
}
+ /// A blob chunk of `bytes` was served as `sent` bytes (fewer if deflated).
+ pub(crate) fn chunk_served(&self, bytes: usize, sent: usize) {
+ let mut inner = self.lock();
+ inner.relay.chunks_served += 1;
+ inner.relay.chunks_deflated += u64::from(sent < bytes);
+ inner.relay.chunk_bytes += bytes as u64;
+ inner.relay.chunk_bytes_sent += sent as u64;
+ }
+
/// A sync message of `from` bytes went out deflated to `to`.
pub(crate) fn deflated(&self, from: usize, to: usize) {
let mut inner = self.lock();