Expand description
Event handler — gift wrap receive, unwrap, process, commit pipeline.
Two-phase architecture:
- Phase 1 (
prepare_event): Parallel-safe — dedup, unwrap, process_rumor - Phase 2 (
commit_prepared_event): Sequential — save DB, update STATE, emit
Platform-specific behavior (notifications) handled by InboundEventHandler trait.
Structs§
- Batching
Persist - Wraps any handler for a bulk-sync drain loop: every callback delegates to the inner
handler, but committed messages BUFFER here instead of saving one transaction each —
the loop calls
BatchingPersist::flushperiodically and at stream end to land them in batched transactions (save_messages_batch_multi). - Live
Only - For catch-up syncs: forwards to
inneronly what is live rather than history. Mini App peer signals and Community invites always: each is live state, and a sync that opens one ledgers its wrapper, so the live subscription will never deliver it again. Withfrom, also messages, reactions, edits and deletions sent since that moment: a sync may be the only path that carries them. - NoOp
Event Handler - No-op handler for CLI/tests.
Enums§
- Prepared
Event - Result of Phase 1 (prepare_event) — everything needed for sequential commit.
Constants§
- DIRECT_
INVITE_ LIFETIME_ SECS - Phase 2: commit a prepared event (sequential — not parallel-safe). Saves to DB, updates STATE, emits to frontend, calls handler hooks. Returns true if a new displayable message was committed.
- UNWRAP_
BATCH - Wraps per
prepare_eventscall on bulk paths (syncs, catch-up). Their seal signatures are checked in one batch, so a bigger batch checks each for less; the vault still opens themcrate::crypto::WRAPS_PER_VAULT_READat a time. A chunk holds whatever has arrived, up to this many: nothing waits to fill one.
Traits§
- Inbound
Event Handler - Platform-specific callbacks for inbound event processing.
Functions§
- commit_
prepared_ event - prepare_
event - Phase 1: Prepare an event for commit (parallel-safe, no state mutation).
- prepare_
events prepare_eventfor many events, one result per event in order. The wraps that pass dedup are opened together, under one vault read for a local key.- process_
event - Process a single event through the full pipeline (prepare + commit).