diff options
Diffstat (limited to 'src/swarm/sync.rs')
| -rw-r--r-- | src/swarm/sync.rs | 21 |
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 |
