Skip to content

platform-wallet: report each finished DashPay sync pass through PlatformEventHandler #5596

Open

Description

@Claudius-Maginificent

TL;DR: The background DashPay sync gives apps no signal when it finishes, so apps poll a timestamp to learn that contacts, requests or profiles changed.

User story

As a wallet app developer, I want to be told when a DashPay sync pass finishes, as I already am for platform-address, DPNS-marketplace and shielded syncs, so that my contact and request screens refresh right away without polling.

As a DashPay user, I want a new contact request or a contact's new profile to appear as soon as the wallet has it.

Scenario

Base flow

  1. The app starts the DashPay sync coordinator, which runs every 15 seconds.
  2. A contact sends a request, and the next pass stores it in the identity's DashPay state.

Actual behavior

Nothing tells the app. To notice the pass it has to poll the coordinator's last-sync timestamp from its UI loop and rebuild its view whenever the value moves.

Expected behavior

After every pass, the app's event handler hears on_dashpay_sync_completed with the pass summary, as it already does for the sibling coordinators.

Detailed discussion

On v5.1-dev @ 575d961fe0:

Downstream: Dash Evo Tool polls last_sync_unix_seconds() from its frame loop to decide when to rebuild its DashPay view (src/backend_task/dashpay/sync.rs, marked TODO(upstream): on_dashpay_sync_completed).

Proposed change

// events.rs
pub trait PlatformEventHandler: EventHandler {
    /// After every DashPay pass that ran (not after a skipped, re-entrant call).
    fn on_dashpay_sync_completed(&self, _summary: &DashPaySyncSummary) {}
}

impl PlatformEventManager {
    pub fn on_dashpay_sync_completed(&self, summary: &DashPaySyncSummary) {
        // fan out, as on_dpns_marketplace_sync_completed does
    }
}

// manager/dashpay_sync.rs: hold `events: Arc<PlatformEventManager>` as DpnsSyncManager does,
// and at the end of `sync_now`, when `summary.sync_unix_seconds != 0`:
//     self.events.on_dashpay_sync_completed(&summary);

A default no-op method keeps existing handlers compiling. It would also help if the summary listed the identity ids whose DashPay state changed in the pass, so an app can rebuild only those. That is optional; the event alone removes the polling.

Prior work

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

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