DustSyncManager

class DustSyncManager(dustRepository: DustRepository, nodeRpcClient: NodeRpcClient, walletAddress: String, dustSeed: ByteArray, cloudBackupSource: DustCloudBackupSource? = null)

Dust state manager — keeps a single in-memory DustLocalState for the session.

On the first sync the persisted checkpoint (if any) is reused for a fast delta; only a genuinely-empty start falls back to a full genesis sync. Serialize/deserialize is root-lossless (proven by the compact-engine serialize_deserialize_reproduces_root test), so the checkpoint is authoritative across process restarts. On error 170: forceResync does a fresh full sync from genesis.

On a cold start with no local checkpoint, an optional cloudBackupSource (e.g. Google Drive, cross-device) is consulted to seed one before genesis — see maybeSeedCheckpointFromCloud. Null (the default) preserves today's behavior exactly.

Constructors

Link copied to clipboard
constructor(dustRepository: DustRepository, nodeRpcClient: NodeRpcClient, walletAddress: String, dustSeed: ByteArray, cloudBackupSource: DustCloudBackupSource? = null)

Functions

Link copied to clipboard
fun close()

Release native resources.

Link copied to clipboard
suspend fun ensureSynced(onSyncProgress: suspend (eventsProcessed: Int, totalEvents: Int) -> Unit? = null): DustLocalState

Get a synced DustLocalState. First call does full sync (~60s on PREPROD). All subsequent calls return the same in-memory state instantly.

Link copied to clipboard
suspend fun forceResync()

Force a completely fresh sync. Clears everything. For error 170 recovery.

Link copied to clipboard
suspend fun invalidateMemo()

After submit: no-op. State stays in memory.

Link copied to clipboard
suspend fun refreshIncremental(onSyncProgress: suspend (eventsProcessed: Int, totalEvents: Int) -> Unit? = null): DustLocalState

On-demand incremental refresh (UI "refresh" affordance, between-tx freshness): drop the in-memory memo and re-sync, which lands as a fast DELTA on the persisted checkpoint. Unlike forceResync this does NOT delete the checkpoint, so a routine refresh never triggers a full genesis re-sync. forceResync stays reserved for error-170 recovery, where stale roots require a clean rebuild from genesis.