From e63d30c2581033a85489b10c3f5b252fdbb5049e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 03:21:43 +0000 Subject: state: plain writes take a view to write, Automerge's are asked for as such AppState::mutate_doc, mutate_doc_registering and mutate_doc_by hand what they are given a document::view::Write: the member registry, the users, sessions, forgetting and bootstrap write through them, and take whatever kind of document gives it. AppState::mutate_doc_for is for what asks more of an Automerge document than values at paths (the store's API, a remake's host, a store's events), and gives the heads after the write. What reads a view takes one of any size (dyn Write among them). --- src/state/host.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/state/host.rs') diff --git a/src/state/host.rs b/src/state/host.rs index 4ef12a1..357814e 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -13,7 +13,7 @@ use tracing::{debug, error, info}; use super::{AppState, HelloState, NodeLifecycle, StaleView, Standing}; use crate::document::replica::{Epoch, Replica}; use crate::document::store::{ChangeSet, StoreError}; -use crate::document::{ChangeHash, Document, ReadDoc, Transaction}; +use crate::document::{ChangeHash, Document, Transaction}; use crate::locks::RwLockExt; use crate::remake::{BegunRejoin, Host, PeerSummary, RemakeState}; @@ -286,7 +286,11 @@ impl Host for AppState { crate::swarm::skew::measure(self).await } - fn electorate(&self, doc: &impl ReadDoc, now: crate::clock::UnixMillis) -> Vec { + fn electorate( + &self, + doc: &(impl crate::document::view::Read + ?Sized), + now: crate::clock::UnixMillis, + ) -> Vec { let electorate = crate::swarm::members::electorate(doc, now.as_u64(), self.electorate_window); // Holding a store: the members the fold names, with the party their entries name; @@ -387,7 +391,12 @@ impl Host for AppState { E: From + Send + 'static, { let state = self.clone(); - async move { state.mutate_doc(f).await } + async move { + state + .mutate_doc_for(None, crate::document::signatures::Sign::Protocol, f) + .await + .map(|(out, _)| out) + } } fn commit_doc_for( -- cgit v1.3.1