DustSubscriptionManager
@Singleton
Manages subscription to dust-related blockchain events and syncs them to DustLocalState.
Workflow:
Indexer (GraphQL) → Subscribe to events → Filter dust events → Replay into DustLocalState → Update database cacheContent copied to clipboard
Event Processing:
Subscribe to zswap ledger events (all blockchain events)
Filter for dust-specific events (DustInitialUtxo, DustSpendProcessed, etc.)
Batch events and replay into DustLocalState
Save updated state to persistent storage
Sync UTXOs to database cache
Usage:
@Inject lateinit var dustSubscriptionManager: DustSubscriptionManager
dustSubscriptionManager.startDustSync(
address = userAddress,
seed = userSeed
).collect { state ->
when (state) {
is DustSyncState.Syncing -> updateUI("Syncing dust: ${state.progress}%")
is DustSyncState.Synced -> updateUI("Dust synced: ${state.balance}")
is DustSyncState.Error -> showError(state.message)
}
}Content copied to clipboard
See also
/midnight-wallet/packages/dust-wallet/src/Syncing.ts (TypeScript SDK reference)
Functions
Link copied to clipboard
fun startDustSync(address: String, seed: ByteArray, fromEventId: Long? = null): Flow<DustSubscriptionManager.DustSyncState>
Starts dust event synchronization for an address.
Link copied to clipboard
Stops dust synchronization (cancels flow collection).