startDustSync

fun startDustSync(address: String, seed: ByteArray, fromEventId: Long? = null): Flow<DustSubscriptionManager.DustSyncState>

Starts dust event synchronization for an address.

Process:

  1. Subscribe to zswap ledger events from indexer

  2. Filter for dust events only

  3. Batch events into groups of EVENT_BATCH_SIZE

  4. Replay batches into DustLocalState

  5. Save state and sync to database cache

  6. Emit progress updates

Resumable: Uses last processed event ID to resume from where it left off. Pass fromEventId to start from specific event (for manual sync).

Error Handling:

  • Network errors: Automatically retries (handled by IndexerClient)

  • Deserialization errors: Skips invalid events, logs error

  • State errors: Emits Error state, stops sync

Return

Flow of sync state updates

Parameters

address

Wallet address to sync dust for

seed

32-byte seed for deriving DustSecretKey (required for replay)

fromEventId

Start from this event ID (null = last synced or latest)