diff options
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 |
