From 2ae7562083f5f96490f90e9398762cf6a024d51e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 04:00:43 +0000 Subject: document: a unit's name, which the swarm passes on by document::UnitId: the name of a unit of a document as its kind has it, an Automerge change's hash. What the swarm announces, forwards along trees, tells a peer it refused and drops is named so (the dissemination, relay, refusals, AppState::drop_taken), and the session is told so what a peer gets from another; a change's hash it is where the document is asked, and on the wire. --- src/swarm/refusals.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/swarm/refusals.rs') diff --git a/src/swarm/refusals.rs b/src/swarm/refusals.rs index 652f9bc..bdc727e 100644 --- a/src/swarm/refusals.rs +++ b/src/swarm/refusals.rs @@ -18,7 +18,7 @@ use std::time::Duration; use tracing::{debug, warn}; -use crate::document::ChangeHash; +use crate::document::UnitId; use crate::document::replica::Epoch; use crate::state::AppState; use crate::transport::{ParsedMessage, RefusalsMessage}; @@ -34,13 +34,13 @@ pub(crate) async fn tell( peer: &str, epoch: Epoch, epoch_seq: u32, - mut changes: Vec, + mut changes: Vec, ) { changes.truncate(MAX_LISTED); let message = ParsedMessage::Refusals(RefusalsMessage { epoch, epoch_seq, - changes, + changes: changes.into_iter().map(Into::into).collect(), }); if let Err(error) = state.transport.send_message(peer, &message).await { // Told again with the next refusal. @@ -53,7 +53,12 @@ pub(crate) async fn tell( pub(crate) async fn received(state: &AppState, peer: &str, message: RefusalsMessage) { let doc = std::sync::Arc::clone(&state.doc); let screening = std::sync::Arc::clone(&state.screening); - let changes: Vec = message.changes.into_iter().take(MAX_LISTED).collect(); + let changes: Vec = message + .changes + .into_iter() + .take(MAX_LISTED) + .map(Into::into) + .collect(); let judged = tokio::task::spawn_blocking(move || { use crate::locks::MutexExt; let replica = doc.blocking_read(); @@ -76,7 +81,7 @@ pub(crate) async fn received(state: &AppState, peer: &str, message: RefusalsMess let mut refused = None; let mut taken = Vec::new(); for hash in changes { - match crate::access::rules::judge_held(&replica.doc, replica.epoch, &hash) { + match crate::access::rules::judge_held(&replica.doc, replica.epoch, &hash.into()) { Some(Err(why)) => { refused = Some((hash, why)); break; -- cgit v1.3.1