aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/replica.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 13:26:25 +0100
committertv <tv@krebsco.de>2026-10-31 13:26:25 +0100
commit7bd73796b22b2ffdf51cb4cce14796fb4381bfaf (patch)
treed78d071b365924c9f12b4bb7a23cc1416001e9d0 /src/document/replica.rs
parent42181c43c9a1ebecaee38e71e3fcfa2384d1c1e6 (diff)
commits go through the replica
Diffstat (limited to 'src/document/replica.rs')
-rw-r--r--src/document/replica.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/document/replica.rs b/src/document/replica.rs
index 8640c7e..5d3d7a7 100644
--- a/src/document/replica.rs
+++ b/src/document/replica.rs
@@ -167,6 +167,19 @@ impl Replica {
pub(crate) fn stamps(&self) -> watch::Receiver<Stamp> {
self.stamp.subscribe()
}
+
+ /// The writes since the last commit, as one change stamped `at`: receivers tell by
+ /// it how long the change took to reach them (`swarm::stats`).
+ pub(crate) fn commit(&mut self, at: crate::clock::UnixMillis) {
+ self.doc.commit_with(
+ automerge::transaction::CommitOptions::default().with_time(at.as_u64() as i64),
+ );
+ }
+
+ /// The writes since the last commit, discarded.
+ pub(crate) fn rollback(&mut self) {
+ self.doc.rollback();
+ }
}
impl Deref for Replica {