Skip to content

feat(swift-sdk): off-main castContestedResourceVote #5875

Open

Description

@romchornyi

Expected Behavior

A client can cast a masternode vote on a contested resource without blocking the main thread, as it already can for the DPNS contest reads (dpnsContestVoteStateOffMain, dpnsContestIsOpenOffMain).

Current Behavior

SDK.castContestedResourceVote(...) (packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift) sits in the @MainActor extension and calls dash_sdk_contested_resource_cast_vote directly; the Rust side runs runtime.block_on(...put_vote(...)). Each broadcast therefore blocks the caller's main thread for the whole network round trip. A wallet voting with many masternodes in one run (dashwallet-ios Quick voting) freezes the UI for every vote, and cannot react to the user leaving the screen until the current broadcast returns. Wrapping the call in Task.detached does not help: the method's isolation hops back to the main actor.

Possible Solution

Add a nonisolated async castContestedResourceVoteOffMain(...) that runs the FFI call on the SDK's Platform queue (the same shape as the other …OffMain methods), keeping the key bytes alive for the duration of the call.

Alternatives Considered

None on the client side; the app cannot call the actor-isolated method off the main actor.

Additional Context

Found in review of dashpay/dashwallet-ios#1366 (username voting redesign); the wallet side waits for this API.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions