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:
2026-10-13 19:24:12 -05:00
co-authored by Claude Opus 4.8
parent f1b0ae5ce7
commit e1003cba43
5 changed files with 54 additions and 11 deletions
+13
View File
@@ -44,6 +44,7 @@
#include "services/wallet_scan_governor.h"
#include "services/scan_policy.h"
#include "services/connect_scan_gate.h"
#include "services/seed_migration_poll.h"
#include "services/chat_scan_policy.h"
#include "services/mining_thread_commit.h"
#include "services/network_refresh_service.h"
@@ -18292,6 +18293,17 @@ void testLiteWalletExistsCache()
dragonx::test::g_liteFakeWalletExists = true; // restore default for later tests
}
void testMigrationWantsBalanceScan()
{
using dragonx::services::migrationWantsBalanceScan;
EXPECT_FALSE(migrationWantsBalanceScan(false, false, 0, -1.0)); // not mined
EXPECT_TRUE(migrationWantsBalanceScan(false, false, 1, -1.0)); // mined, no figure yet
EXPECT_FALSE(migrationWantsBalanceScan(false, false, 3, 0.0)); // already scanned
EXPECT_FALSE(migrationWantsBalanceScan(false, false, 3, 2.5)); // already scanned (remainder)
EXPECT_TRUE(migrationWantsBalanceScan(true, true, 0, 0.0)); // forced overrides sync / unmined
EXPECT_FALSE(migrationWantsBalanceScan(false, true, 1, -1.0)); // syncing defers the automatic scan
}
int main()
{
testConnectionConfig();
@@ -18348,6 +18360,7 @@ int main()
testRefreshProfileSelection();
testConnectionInfoSeeding();
testConnectScanGate();
testMigrationWantsBalanceScan();
testScanPolicy();
testChatScanPolicy();
testChooseChatPayer();