aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/stats.rs8
-rw-r--r--src/swarm/sync.rs3
2 files changed, 10 insertions, 1 deletions
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index c322305..b51a802 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -143,6 +143,9 @@ pub(crate) struct Relay {
pub(crate) carrying_bloom_bytes: u64,
pub(crate) nothing_new_change_bytes: u64,
pub(crate) nothing_new_bloom_bytes: u64,
+ /// The changes new to us that sync messages brought (beside what they carried that
+ /// we had): with `carrying` less `nothing_new`, how many a message with news brings.
+ pub(crate) new_changes: u64,
/// Changes from elsewhere that came not along a writer's tree (pulled, with an
/// answer, sent again, fetched as a delta), and their delays summed (as `Propagation`).
pub(crate) off_tree: u64,
@@ -282,6 +285,11 @@ impl NodeStats {
inner.relay.carrying_bloom_bytes += sizes.1 as u64;
}
+ /// A sync message brought `count` changes new to us.
+ pub(crate) fn new_changes(&self, count: usize) {
+ self.lock().relay.new_changes += count as u64;
+ }
+
/// A sync message of `bytes` arrived.
pub(crate) fn sync_received(&self, bytes: usize) {
let mut inner = self.lock();
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 2a08aae..9a63c8b 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -506,7 +506,8 @@ pub(crate) async fn handle_sync(
let changed = heads_after != heads_before;
if changed {
// They came from it: none goes back (`SyncSession::came_from_peer`).
- peer_state.sync.came_from_peer(&replica.doc, &heads_before);
+ let new = peer_state.sync.came_from_peer(&replica.doc, &heads_before);
+ stats.new_changes(new);
}
if carried && !changed {
stats.nothing_new(payload_len, writer.is_some(), delivered, sizes);