From 46978f2b6b102750bcc8eef3b0b286b6008240f7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2026 21:47:21 +0000 Subject: signatures: tell held changes as the screen does With every message's signatures offered now (1205), Signatures::offer runs for each, and it asked get_change_meta_by_hash whether the document holds each signature's change, and each one waiting, up to 4096 of them: Automerge rebuilds the change's metadata from the document's operations to answer. Ask changes::holds instead (1197), there and in forks and kept_for; the metadata is still read where it is used. --- src/document/signatures.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/document/signatures.rs b/src/document/signatures.rs index 27bbb9e..2f408d5 100644 --- a/src/document/signatures.rs +++ b/src/document/signatures.rs @@ -295,7 +295,7 @@ impl Signatures { let kept = self .order .iter() - .filter(|hash| doc.get_change_meta_by_hash(hash).is_some()) + .filter(|hash| super::changes::holds(doc, hash)) .map(|hash| (*hash, self.by_change[hash])) .collect(); Self { @@ -353,7 +353,7 @@ impl Signatures { pub(crate) fn offer(&mut self, doc: &Document, received: Vec<(ChangeHash, [u8; 64])>) -> usize { let mut kept = 0; for (hash, signature) in received { - if doc.get_change_meta_by_hash(&hash).is_none() { + if !super::changes::holds(doc, &hash) { self.pending.insert(hash, signature); } else if self.vouch(doc, hash, &signature) { self.insert(hash, signature); @@ -363,7 +363,7 @@ impl Signatures { let arrived: Vec = self .pending .keys() - .filter(|hash| doc.get_change_meta_by_hash(hash).is_some()) + .filter(|hash| super::changes::holds(doc, hash)) .copied() .collect(); for hash in arrived { @@ -455,7 +455,7 @@ impl Signatures { /// sign one. pub(crate) fn forks(&self, doc: &Document, change: &super::Change) -> bool { self.latest.get(change.actor_id()).is_some_and(|latest| { - latest.seq >= change.seq() && doc.get_change_meta_by_hash(&latest.hash).is_some() + latest.seq >= change.seq() && super::changes::holds(doc, &latest.hash) }) } -- cgit v1.3.1