perf(history): add a transactions revision counter to WalletState
WalletState had no change signal for its transaction list, so a UI cache had to fingerprint all N transactions every frame to notice an update. It now carries tx_revision, a counter that only increases; clear() on disconnect bumps it instead of resetting it, so a cache built before a reconnect or wallet switch can never match again. - Every writer of the list bumps it: the full-node refresh, loading the cached history, adding, completing and removing a pending send, a mining-address relabel, the lite refresh and the screenshot demo rows. - The full-node refresh and the lite refresh (every ~2 s) swap in the new list only when it differs field by field, the amount compared bit-exactly because -0.0 and +0.0 print differently. An unchanged refresh keeps the list and the revision; the compare costs O(N) per refresh, not per frame. Nothing reads the counter yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -326,7 +326,9 @@ void applyLiteRefreshModelToWalletState(const LiteWalletAppRefreshModel& model,
|
||||
}
|
||||
|
||||
if (model.hasTransactions) {
|
||||
state.transactions.clear();
|
||||
// Build aside and swap in only on a real change: this runs every ~2 s, and a bump rebuilds History.
|
||||
std::vector<TransactionInfo> nextTransactions;
|
||||
nextTransactions.reserve(model.transactions.size());
|
||||
const int64_t chainHeight =
|
||||
model.hasSyncStatus ? static_cast<int64_t>(model.sync.chainHeight) : 0;
|
||||
for (const auto& record : model.transactions) {
|
||||
@@ -356,8 +358,9 @@ void applyLiteRefreshModelToWalletState(const LiteWalletAppRefreshModel& model,
|
||||
const int64_t confs = chainHeight - *record.blockHeight + 1;
|
||||
tx.confirmations = confs > 0 ? static_cast<int>(confs) : 0;
|
||||
}
|
||||
state.transactions.push_back(std::move(tx));
|
||||
nextTransactions.push_back(std::move(tx));
|
||||
}
|
||||
state.setTransactionsIfChanged(std::move(nextTransactions));
|
||||
}
|
||||
|
||||
if (model.hasSyncStatus) {
|
||||
|
||||
Reference in New Issue
Block a user