File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments