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 | 0c5e612550e399c3aad458d5c1d70e5cc4267a15 (patch) | |
| tree | acd8b3a08da2fd256702af6b70e41d6b1ebaaad7 /src/document | |
| parent | 694347ad456766004e2792c4b4cda865a8a40386 (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 { |
