aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/changes.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/document/changes.rs b/src/document/changes.rs
index 1091261..9a07fc0 100644
--- a/src/document/changes.rs
+++ b/src/document/changes.rs
@@ -8,6 +8,13 @@ use anyhow::{Context, Result, anyhow, bail};
use super::{Change, ChangeHash, Document, ReadDoc};
+/// Whether `doc` has every change of `heads`.
+pub(crate) fn holds_all(doc: &Document, heads: &[ChangeHash]) -> bool {
+ heads
+ .iter()
+ .all(|head| doc.get_change_by_hash(head).is_some())
+}
+
/// Whether the history of `theirs` (of them, those `doc` has) holds all of `ours`
/// (heads of `doc`): a peer at `theirs` has every change we have.
pub(crate) fn covers(doc: &Document, theirs: &[ChangeHash], ours: &[ChangeHash]) -> bool {