diff options
Diffstat (limited to 'src/federation/held.rs')
| -rw-r--r-- | src/federation/held.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs index fec21ab..cd53727 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -538,6 +538,10 @@ impl Holding { /// what its store's checkpoint keeps, then what it took after it, then what it holds /// back, stopped (`Store::held_back`). pub(crate) fn lacking(&self, doc: &impl ReadDoc) -> Vec<(Id, Vec<u8>)> { + // A set of events is the store's own document: it lacks none of it. + if self.of_a_set { + return Vec::new(); + } let mut held: HashSet<Id> = events::ids(doc).into_iter().collect(); let mut inner = self.inner.lock_or_recover(); inner.left.retain(|(id, _)| !held.contains(id)); @@ -1344,6 +1348,17 @@ pub(crate) async fn write( bytes: Vec<u8>, ) -> Result<(), store::StoreError> { let id = Id::of(&bytes); + // Into a set of events it goes as the store takes it, where it didn't yet; and is + // passed on, as written. + if state.of_a_set() { + let holding = Arc::clone(&state.holding); + let _ = tokio::task::spawn_blocking(move || holding.offer(bytes)).await; + let held = state.holding.with(|store| store.get(&id).is_some()); + if held == Some(true) { + crate::swarm::set::wrote(state, vec![id]).await; + } + return Ok(()); + } state .mutate_doc_for( user, |
