Skip to content

Commit 2f46a1e

Browse files
committed
fix: inserts proofs before events for self-anchored events, to match the external flow
1 parent 9d992b3 commit 2f46a1e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

event-svc/src/event/store.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,17 @@ impl ceramic_anchor_service::Store for EventService {
264264
// All items in a batch share the same chain inclusion data since they're from the same anchor tx.
265265
let chain_inclusion = items.iter().find_map(|i| i.chain_inclusion.clone());
266266

267+
// Persist chain inclusion proof FIRST for self-anchored events.
268+
// This aligns with the external event flow (service.rs persists proofs before events)
269+
// and ensures events are never orphaned without their chain proofs.
270+
if let Some(chain_data) = chain_inclusion {
271+
let proof: ChainProof = chain_data.into();
272+
self.event_access
273+
.persist_chain_inclusion_proofs(&[proof])
274+
.await
275+
.context("failed to persist chain inclusion proof for self-anchored events")?;
276+
}
277+
267278
let items = items
268279
.into_iter()
269280
.map(|insertable| {
@@ -282,15 +293,6 @@ impl ceramic_anchor_service::Store for EventService {
282293
.await
283294
.context("anchoring insert_many failed")?;
284295

285-
// Persist chain inclusion proof for self-anchored events
286-
if let Some(chain_data) = chain_inclusion {
287-
let proof: ChainProof = chain_data.into();
288-
self.event_access
289-
.persist_chain_inclusion_proofs(&[proof])
290-
.await
291-
.context("failed to persist chain inclusion proof for self-anchored events")?;
292-
}
293-
294296
Ok(())
295297
}
296298

0 commit comments

Comments
 (0)