perf(history): memoize the transaction display list instead of rebuilding it every frame
The History tab rebuilt its entire display list on every render frame: indexing all transactions by txid, merging autoshield send+receive pairs into "shield" rows, and std::sort-ing the result — O(N log N) plus several heap allocations at ~60fps, only to show one 50-row page. The data is already sorted newest-first by the refresh service, so the per-frame sort was redundant on top. Memoize the merged+sorted list, rebuilding only when the underlying transactions actually change. The cache key is a cheap, allocation-free FNV-1a fingerprint over the display-relevant fields (count, last update time, and each tx's confirmations / timestamp / type+address first char) — a new block bumps every confirmation so the key changes and we rebuild; otherwise (the common read/scroll case) the cache is reused. Filtering, search, and pagination still run per-frame over the cached list (cheap linear scans that depend on interactive state). Also document that App::shouldRefreshTransactions() is block-height/dirty driven (not interval-gated) — the Transactions timer only paces the check; the recent-poll handles between-block mempool/unconfirmed deltas. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -716,6 +716,11 @@ void App::setCurrentPage(ui::NavPage page)
|
||||
|
||||
bool App::shouldRefreshTransactions() const
|
||||
{
|
||||
// NOTE: this is block-height / dirty driven, NOT interval-gated. It returns true only when a new
|
||||
// block arrived (currentBlocks != last_tx_block_height_), the history was never fetched, or
|
||||
// something marked it dirty (tab entry, a send, a reorg, etc.). The Transactions timer only
|
||||
// controls how often this CHECK runs; between blocks the lightweight recent-poll
|
||||
// (shouldRefreshRecentTransactions / TxAge) handles mempool + unconfirmed deltas instead.
|
||||
const int currentBlocks = state_.sync.blocks;
|
||||
return network_refresh_.shouldRefreshTransactions(last_tx_block_height_,
|
||||
currentBlocks,
|
||||
|
||||
Reference in New Issue
Block a user