diff options
| author | tv <tv@krebsco.de> | 2026-10-31 13:26:25 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 13:26:25 +0100 |
| commit | f273b1a07e0ea78fb5b91d7916f596db899ab884 (patch) | |
| tree | 9a3d712a006b4101856cb9150eb9676961ddab53 /src/document | |
| parent | baf9498c69340da18001c7ca2c223ed45fddc249 (diff) | |
commits go through the replica
Diffstat (limited to 'src/document')
| -rw-r--r-- | src/document/replica.rs | 13 |
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 { |
