Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ internal object WalletManagerNative {
external fun identitySyncStop(managerHandle: Long)
external fun identitySyncIsRunning(managerHandle: Long): Boolean

/**
* Whether the durable sync watermark has been frozen this session because
* persistence events were dropped or a store was rejected — the persisted
* `syncedHeight` is held behind the chain tip and a rescan is pending on
* the next launch. Latches for the process lifetime.
*/
external fun syncFaultDetected(managerHandle: Long): Boolean

/** Shielded loop — only present when the native library is built with shielded. */
external fun shieldedSyncStart(managerHandle: Long)
external fun shieldedSyncStop(managerHandle: Long)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,21 @@ class PlatformWalletManager(
mapNativeErrors { WalletManagerNative.platformAddressSyncIsRunning(managerHandle) }
}

/**
* Whether the native manager has frozen its durable sync watermark this
* session (dashpay/platform#4069). `true` means the wallet-event adapter
* dropped record-bearing events, or a persistence `store()` was rejected,
* so the persisted `syncedHeight` is deliberately held behind the chain
* tip and a rescan is pending on the next launch. Poll this to surface a
* hard "verification failed / rescan pending" state instead of leaving
* the fault visible only in the error logs.
*
* The flag latches: once `true` it stays `true` for the process lifetime.
*/
suspend fun syncFaultDetected(): Boolean = withContext(Dispatchers.IO) {
mapNativeErrors { WalletManagerNative.syncFaultDetected(managerHandle) }
}

/**
* Reset the platform-address (BLAST) sync state — the native side of the
* Sync tab's "Clear" action (#3959), port of Swift
Expand Down
24 changes: 24 additions & 0 deletions packages/rs-platform-wallet-ffi/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,30 @@ pub unsafe extern "C" fn platform_wallet_manager_persistence_capabilities(
PlatformWalletFFIResult::ok()
}

/// Whether the manager has frozen its durable sync watermark this session
/// (dashpay/platform#4069).
///
/// `true` means the wallet-event adapter dropped record-bearing events (a
/// broadcast lag) or had a persistence `store()` rejected, so the persisted
/// `syncedHeight` is deliberately held behind the chain tip and a rescan is
/// pending on the next launch. Hosts poll this to surface a hard
/// "verification failed / rescan pending" state instead of the fault being
/// visible only in error logs.
///
/// The flag latches: once `true` it stays `true` for the process lifetime.
#[no_mangle]
pub unsafe extern "C" fn platform_wallet_manager_sync_fault_detected(
handle: Handle,
out_detected: *mut bool,
) -> PlatformWalletFFIResult {
check_ptr!(out_detected);

let option =
PLATFORM_WALLET_MANAGER_STORAGE.with_item(handle, |manager| manager.sync_fault_detected());
*out_detected = unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Map the C `has_x: bool` + `x` companion-pair idiom to a Rust `Option<u32>`.
///
/// `has == true` yields `Some(value)` — including `Some(0)`, kept distinct
Expand Down
Loading
Loading