perf(migrate): gate the seed-migration confirming balance scan
While the seed migration sits on the Confirming gate it polled the sweep's confirmations and a full wallet balance together on every pass. That balance call is the expensive one, and it only matters once the sweep is mined and we do not yet have a post-mine figure, yet it ran every poll even mid-sync when it cannot move the gate. - The confirmation count is still read on every poll. - The balance scan now runs only when it can actually advance the adopt gate: the sweep is mined, no post-mine balance has been recorded yet, and no sync is in progress. The manual Refresh button forces it regardless. - The decision lives in a small pure helper, and the poller snapshots the main-thread state it needs rather than reading members off the worker thread. - The Confirming screen now claims a leftover remainder (and offers the re-sweep button) only once the balance has actually been measured; while it is still unknown it keeps waiting instead of prompting on a sentinel. Tests cover the gate helper across the forced, syncing, and mined cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// DragonX Wallet - ImGui Edition
|
||||
// Copyright 2024-2026 The Hush Developers
|
||||
// Released under the GPLv3
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace dragonx {
|
||||
namespace services {
|
||||
|
||||
// The expensive z_gettotalbalance only changes the seed-migration adopt gate once the sweep is mined and
|
||||
// we have no post-mine figure yet (priorRemaining < 0). A manual Refresh forces it; an active sync
|
||||
// suppresses the automatic scan (the Refresh button still overrides).
|
||||
inline bool migrationWantsBalanceScan(bool forceBalance, bool syncing, int confs, double priorRemaining)
|
||||
{
|
||||
if (forceBalance) return true;
|
||||
return !syncing && confs >= 1 && priorRemaining < 0.0;
|
||||
}
|
||||
|
||||
} // namespace services
|
||||
} // namespace dragonx
|
||||
Reference in New Issue
Block a user