diff options
| author | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
| commit | 6105507200231e67ba544c12aa10b988e1c23826 (patch) | |
| tree | 880530b7401cb5d43f52e06a68b4d704326aa272 /src/swarm/changes.rs | |
| parent | 8d7adfbdb7798cca9d9783761f290e3bd85d9a3a (diff) | |
use Automerge as Document instead of AutoCommit
This allows a lot of operations to drop mut.
Diffstat (limited to 'src/swarm/changes.rs')
| -rw-r--r-- | src/swarm/changes.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/swarm/changes.rs b/src/swarm/changes.rs index 3a50769..7f3c2e9 100644 --- a/src/swarm/changes.rs +++ b/src/swarm/changes.rs @@ -21,9 +21,8 @@ pub(crate) async fn run_change_publisher(state: AppState) { let before = last_heads.clone(); let doc = Arc::clone(&state.doc); - // Looking changes up needs the document mutably. let (heads, paths, conflicts) = tokio::task::spawn_blocking(move || { - let mut replica = doc.blocking_write(); + let replica = doc.blocking_read(); let heads = replica.heads().to_vec(); if heads == before { return (heads, Vec::new(), Vec::new()); @@ -31,13 +30,13 @@ pub(crate) async fn run_change_publisher(state: AppState) { // After an epoch switch the previous heads belong to the old document: // report the root as changed, which every stream is related to. - if !changes::missing(&mut replica.doc, &before).is_empty() { + if !changes::missing(&replica.doc, &before).is_empty() { return (heads, vec![Vec::new()], Vec::new()); } let mut paths = Vec::new(); let mut conflicts = Vec::new(); - for changed in store::changed(&mut replica.doc, &before, &heads, InLists::Index) { + for changed in store::changed(&replica.doc, &before, &heads, InLists::Index) { if changed.conflict { conflicts.push(changed.path.clone()); } |
