aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 03:21:43 +0000
committertv <tv@krebsco.de>2026-11-29 03:21:43 +0000
commite63d30c2581033a85489b10c3f5b252fdbb5049e (patch)
tree5f4e6f65f1cecfb32f841e7ad7d9d106aeb69b20 /src/federation
parent9188fa6e13ea7facfab5fb6f55bf26444ec2c01e (diff)
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).
Diffstat (limited to 'src/federation')
-rw-r--r--src/federation/held.rs41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs
index 72633eb..ec3738f 100644
--- a/src/federation/held.rs
+++ b/src/federation/held.rs
@@ -1251,25 +1251,30 @@ pub(crate) async fn write(
async fn put_again(state: &crate::state::AppState) {
let holding = Arc::clone(&state.holding);
let put = state
- .mutate_doc(move |doc| {
- let mut bytes_put = 0;
- let mut put = 0;
- for (id, bytes) in holding.lacking(doc) {
- if bytes_put > 0 && bytes_put + bytes.len() > PUT_BYTES {
- break;
+ .mutate_doc_for(
+ None,
+ crate::document::signatures::Sign::Protocol,
+ move |doc| {
+ let mut bytes_put = 0;
+ let mut put = 0;
+ for (id, bytes) in holding.lacking(doc) {
+ if bytes_put > 0 && bytes_put + bytes.len() > PUT_BYTES {
+ break;
+ }
+ bytes_put += bytes.len();
+ store::write_val_path(
+ doc,
+ &events::event(&id),
+ &crate::document::typed::Val::Scalar(ScalarValue::Bytes(bytes)),
+ store::Writing::sticky(Default::default()),
+ )?;
+ put += 1;
}
- bytes_put += bytes.len();
- store::write_val_path(
- doc,
- &events::event(&id),
- &crate::document::typed::Val::Scalar(ScalarValue::Bytes(bytes)),
- store::Writing::sticky(Default::default()),
- )?;
- put += 1;
- }
- Ok::<usize, store::StoreError>(put)
- })
- .await;
+ Ok::<usize, store::StoreError>(put)
+ },
+ )
+ .await
+ .map(|(put, _)| put);
match put {
Ok(0) => {}
Ok(put) => info!(put, "Put again events the document lacked"),