aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 01:23:40 +0100
committertv <tv@krebsco.de>2026-11-05 01:23:40 +0100
commit889e23ee1eb8a209efe7c1eae86aa39091560149 (patch)
tree8da04d6d62f9a1647f90b6ea459eba62b91f5a12 /src/swarm/sync.rs
parent0d16147e95211b0829fddaefb0d014fe0c48dbc8 (diff)
covered neighbours have it
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 9a63c8b..c76c16b 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -446,10 +446,15 @@ pub(crate) async fn handle_sync(
let clock = Arc::clone(&state.clock);
let ahead_ms = state.clock_ahead_ms.load(Ordering::Relaxed);
- // Some((caught_up, heads changed, carried changes, the new changes' authors and
- // whether any has none)) when applied, None when the message belongs to another
- // epoch.
- type Applied = (bool, bool, bool, (Vec<String>, bool));
+ // Some((caught_up, heads changed, carried changes, the new changes' authors with
+ // theirs, and whether any has none)) when applied, None when the message belongs
+ // to another epoch.
+ type Applied = (
+ bool,
+ bool,
+ bool,
+ (Vec<(String, Vec<crate::document::ChangeHash>)>, bool),
+ );
tokio::task::spawn_blocking(move || -> Result<Option<Applied>> {
// Before the lock: decoding a large message takes a while.
let payload_len = message.0.len();
@@ -572,9 +577,9 @@ pub(crate) async fn handle_sync(
crate::swarm::relay::pulled(state, peer);
// Caught up: our other neighbours may lack what the source had.
if changed || just_caught_up {
- let writers: Vec<u64> = authors
- .iter()
- .map(|author| crate::swarm::topology::pair_key(author))
+ let writers: Vec<(u64, Vec<crate::document::ChangeHash>)> = authors
+ .into_iter()
+ .map(|(author, changes)| (crate::swarm::topology::pair_key(&author), changes))
.collect();
crate::swarm::relay::announce(state, peer, &writers, unauthored).await;
} else if carried
@@ -584,7 +589,7 @@ pub(crate) async fn handle_sync(
// A writer's changes along its tree that we had already: they came another way
// first, not saying whose (with an answer to one of our messages, say), so we
// passed nothing on then. Our children in its tree may lack them still.
- crate::swarm::tree::forward(state, writer, peer).await;
+ crate::swarm::tree::forward(state, writer, peer, &[]).await;
}
state