diff --git a/crates/community/src/community.rs b/crates/community/src/community.rs index 1cff92fe..032d35a8 100644 --- a/crates/community/src/community.rs +++ b/crates/community/src/community.rs @@ -762,6 +762,17 @@ impl Community { let mut held = Vec::with_capacity(base.stepped.len() + self.state.held_roots.len()); for key in base.stepped { + let known = self + .state + .held_roots + .iter() + .chain(held.iter()) + .any(|root| root.epoch == key.epoch && root.key == key.key); + + if known { + continue; + } + held.push(HeldRoot { epoch: key.epoch, key: key.key, @@ -770,7 +781,17 @@ impl Community { }); } - held.extend(self.state.held_roots.iter().copied()); + for root in &self.state.held_roots { + if held + .iter() + .any(|kept| kept.epoch == root.epoch && kept.key == root.key) + { + continue; + } + + held.push(*root); + } + self.state.held_roots = held; if let Some(control_pk) = base.control_pk { diff --git a/crates/community/src/sync.rs b/crates/community/src/sync.rs index 8a3b1ab1..ec2d2da3 100644 --- a/crates/community/src/sync.rs +++ b/crates/community/src/sync.rs @@ -628,6 +628,11 @@ pub async fn fold(client: &Client, state: &CommunityState) -> Result