aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
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
commit0c5e612550e399c3aad458d5c1d70e5cc4267a15 (patch)
treeacd8b3a08da2fd256702af6b70e41d6b1ebaaad7 /src/state
parent694347ad456766004e2792c4b4cda865a8a40386 (diff)
commits go through the replica
Diffstat (limited to 'src/state')
-rw-r--r--src/state/mod.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs
index efa4953..cf64dc3 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -413,7 +413,7 @@ impl AppState {
.expect("document write task panicked")
}
- /// Mutates the document on the blocking pool as one Automerge change, then
+ /// Mutates the document on the blocking pool as one change, then
/// publishes it. Write and notification run in the same blocking task, so a
/// cancelled request can't leave a committed write unannounced.
pub(crate) async fn mutate_doc<T, E>(
@@ -431,19 +431,10 @@ impl AppState {
let mut replica = state.doc.blocking_write();
let result = f(&mut replica.doc);
match &result {
- // One API write = one Automerge change.
- Ok(_) => {
- // Stamped with our clock (milliseconds), so receivers can tell
- // how long the change took to reach them (`swarm::stats`).
- replica.doc.commit_with(
- automerge::transaction::CommitOptions::default()
- .with_time(state.clock.now_millis().as_u64() as i64),
- );
- }
+ // One API write = one change.
+ Ok(_) => replica.commit(state.clock.now_millis()),
// Discard partial ops (e.g. old value deleted, new one not written).
- Err(_) => {
- replica.doc.rollback();
- }
+ Err(_) => replica.rollback(),
}
replica.refresh_heads();
result