perf(net): hold wallet scans at connect, in the background and on tab entry
- Connect gate: after the node starts answering, wallet scans wait until the lock state is known and the node knows its tip (or the wallet has fewer than 500 transactions), at most 20 s. A node already behind latches the sync profile from the connect's getinfo. Meanwhile a list-only pass keeps the address list and the cached history up, and the session's first balance and per-address balances are read once even while catching up, so the wallet shows its last-synced values instead of 0. - Background: minimized, hidden, or covered without focus (3 s debounce, any input cancels) polls only the chain state every 15 s. Wallet scans, the mining poll, price, nudges and auto-lock interaction tracking pause; auto-lock now fires while minimized. Leaving a held profile marks every timer due again. - Tab entry marks the timers due instead of forcing scans; a stale list or a never-loaded history still loads on entry. - The scan entry points own the hard gates, failed enumerations keep the previous lists behind a retry hold, and failed balance calls never overwrite known balances with 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,7 @@ public:
|
||||
bool ok = false;
|
||||
bool encrypted = false;
|
||||
std::int64_t unlockedUntil = 0;
|
||||
std::optional<int> txCount; // getwalletinfo's txcount (the wallet's transactions)
|
||||
};
|
||||
|
||||
struct WarmupPollResult {
|
||||
@@ -147,6 +148,7 @@ public:
|
||||
bool needSpendable = true;
|
||||
std::optional<std::int64_t> prevTotalZat;
|
||||
bool fetchMempool = false; // add getmempoolinfo after a successful getblockchaininfo
|
||||
bool evenIfBehind = false; // the session's first balance read: also while the node is behind
|
||||
};
|
||||
|
||||
struct MiningRefreshResult {
|
||||
@@ -208,6 +210,10 @@ public:
|
||||
std::vector<UnspentNoteLite> unspentNotes;
|
||||
bool balancesOk = true; // false: a balance call failed, the per-address balances may be stale
|
||||
bool replyTimedOut = false; // a call hit the reply timeout (the daemon kept running it)
|
||||
// The lists only: no z_listunspent / listunspent, or a balance call failed (the pass then degrades to
|
||||
// list-only). Applying it carries the previous balances over.
|
||||
bool listOnly = false;
|
||||
bool nodeBusy = false; // a call failed because the node was busy (timeout, full queue, held back)
|
||||
};
|
||||
|
||||
struct AddressRefreshSnapshot {
|
||||
@@ -317,6 +323,10 @@ public:
|
||||
static Intervals intervalsForPage(ui::NavPage page) { return RefreshScheduler::intervalsForPage(page); }
|
||||
|
||||
static ConnectionInfoResult parseConnectionInfoResult(const nlohmann::json& info);
|
||||
// The node knows the chain tip: longestchain stays 0 after a start until its first UpdateTip.
|
||||
static bool connectionInfoTipKnown(const ConnectionInfoResult& info);
|
||||
// The tip is known and the node is more than 2 blocks behind it (the sync tolerance).
|
||||
static bool connectionInfoShowsBehind(const ConnectionInfoResult& info);
|
||||
static WalletEncryptionResult parseWalletEncryptionResult(const nlohmann::json& walletInfo);
|
||||
static WarmupPollResult collectWarmupPollResult(RefreshRpcGateway& rpc);
|
||||
static ConnectionInitResult collectConnectionInitResult(
|
||||
@@ -378,9 +388,13 @@ public:
|
||||
static void applyTransparentBalancesFromUnspent(std::vector<AddressInfo>& addresses,
|
||||
const nlohmann::json& unspent);
|
||||
static AddressRefreshSnapshot buildAddressRefreshSnapshot(const WalletState& state);
|
||||
// listOnly: enumerate the addresses only (cheap), without the wallet-wide balance scans; for while the
|
||||
// scans are held (the node catching up, the connect gate). Both lists are enumerated first, and the
|
||||
// balances are scanned only when both enumerations succeeded (a failed pass is discarded whole).
|
||||
static AddressRefreshResult collectAddressRefreshResult(
|
||||
RefreshRpcGateway& rpc,
|
||||
const AddressRefreshSnapshot& snapshot = {});
|
||||
const AddressRefreshSnapshot& snapshot = {},
|
||||
bool listOnly = false);
|
||||
static TransactionRefreshSnapshot buildTransactionRefreshSnapshot(const WalletState& state,
|
||||
const TransactionViewCache& viewTxCache,
|
||||
const std::unordered_set<std::string>& sendTxids);
|
||||
|
||||
Reference in New Issue
Block a user