aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-03 06:46:44 +0100
committertv <tv@krebsco.de>2026-11-03 06:46:44 +0100
commitaf0b36a1532311669303dc8134bf74e2d607ef0c (patch)
tree1791788fafeaf8a27fc9228dbc2d5c9b3db81021 /src/document
parent0617951a2936a8dd7c64eb05a3605893cc9d73f1 (diff)
writers from authors
Diffstat (limited to 'src/document')
-rw-r--r--src/document/changes.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/document/changes.rs b/src/document/changes.rs
index 92b7744..faba895 100644
--- a/src/document/changes.rs
+++ b/src/document/changes.rs
@@ -27,6 +27,28 @@ pub(crate) fn commit_times(doc: &Document, since: &[ChangeHash]) -> Vec<i64> {
.collect()
}
+/// Who wrote the changes after `since`: the authors their writers set (a node's ID,
+/// `replica::authored`), each once; and whether any change has none (a snapshot, or a
+/// change of a node that set none).
+pub(crate) fn authors_since(doc: &Document, since: &[ChangeHash]) -> (Vec<String>, bool) {
+ let mut authors: Vec<String> = Vec::new();
+ let mut unknown = false;
+ for change in doc.get_changes_meta(since) {
+ match change
+ .author
+ .as_ref()
+ .and_then(|author| std::str::from_utf8(author.as_bytes()).ok())
+ {
+ Some(author) if !authors.iter().any(|known| known == author) => {
+ authors.push(author.to_owned());
+ }
+ Some(_) => {}
+ None => unknown = true,
+ }
+ }
+ (authors, unknown)
+}
+
/// The change `hash` as the document encodes it; None if `doc` doesn't have it.
pub(crate) fn change_bytes(doc: &Document, hash: &ChangeHash) -> Option<Vec<u8>> {
doc.get_change_by_hash(hash)