From 0c5e612550e399c3aad458d5c1d70e5cc4267a15 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 13:26:25 +0100 Subject: commits go through the replica --- src/document/replica.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/document') 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 { 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 { -- cgit v1.3.1