aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/refusals.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 04:00:43 +0000
committertv <tv@krebsco.de>2026-11-29 04:00:43 +0000
commit2ae7562083f5f96490f90e9398762cf6a024d51e (patch)
tree5e23c6bda5682e39413fe557348023cc4204d487 /src/swarm/refusals.rs
parentf497cf6ef14de8204bc1edec078116593d791b97 (diff)
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.
Diffstat (limited to 'src/swarm/refusals.rs')
-rw-r--r--src/swarm/refusals.rs15
1 files changed, 10 insertions, 5 deletions
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<ChangeHash>,
+ mut changes: Vec<UnitId>,
) {
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<ChangeHash> = message.changes.into_iter().take(MAX_LISTED).collect();
+ let changes: Vec<UnitId> = 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;