diff options
| author | tv <tv@krebsco.de> | 2026-11-05 16:12:30 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-05 16:12:30 +0100 |
| commit | 250f99172058f733de3215703173115695297878 (patch) | |
| tree | 85279d13cdedf924ed8ec563c9fc906922758f3a /src/document/sync.rs | |
| parent | 63acf8447f7702a6d083b8ed602eafdf2ff7f6d9 (diff) | |
one walk since
Diffstat (limited to 'src/document/sync.rs')
| -rw-r--r-- | src/document/sync.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs index bfa0fef..688d455 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -564,11 +564,18 @@ impl SyncSession { doc: &Document, before: &[crate::document::ChangeHash], ) -> usize { - let changes = doc.get_changes_meta(before); - for change in &changes { - self.state.sent_hashes.insert(change.hash); - } - changes.len() + let hashes: Vec<_> = doc + .get_changes_meta(before) + .iter() + .map(|c| c.hash) + .collect(); + self.these_came_from_peer(&hashes) + } + + /// `came_from_peer`, for the changes `hashes` (found already). + pub(crate) fn these_came_from_peer(&mut self, hashes: &[crate::document::ChangeHash]) -> usize { + self.state.sent_hashes.extend(hashes.iter().copied()); + hashes.len() } /// Of the changes in `doc` beyond `from`, how many the peer has too, as far as we |
