aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-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 {