From 56a0d89b888c861e49b91060362fd682abbfbcd5 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 4 May 2024 17:08:38 +0000 Subject: [PATCH] Improve deferred mempool visualization updates --- .../block-overview-graph.component.ts | 10 ++++++++-- .../mempool-block-overview.component.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts b/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts index 57db9bfca..ceb12738d 100644 --- a/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts +++ b/frontend/src/app/components/block-overview-graph/block-overview-graph.component.ts @@ -238,7 +238,7 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On } } - // collates non-urgent updates into a set of consistent pending changes + // collates deferred updates into a set of consistent pending changes queueUpdate(add: TransactionStripped[], remove: string[], change: { txid: string, rate: number | undefined, acc: boolean | undefined }[], direction: string = 'left'): void { for (const tx of add) { this.pendingUpdate.add[tx.txid] = tx; @@ -262,9 +262,15 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On this.pendingUpdate.count++; } + deferredUpdate(add: TransactionStripped[], remove: string[], change: { txid: string, rate: number | undefined, acc: boolean | undefined }[], direction: string = 'left'): void { + this.queueUpdate(add, remove, change, direction); + this.applyQueuedUpdates(); + } + applyQueuedUpdates(): void { if (this.pendingUpdate.count && performance.now() > (this.lastUpdate + this.animationDuration)) { - this.update([], [], [], this.pendingUpdate?.direction); + this.applyUpdate(Object.values(this.pendingUpdate.add), Object.values(this.pendingUpdate.remove), Object.values(this.pendingUpdate.change), this.pendingUpdate.direction); + this.clearUpdateQueue(); } } diff --git a/frontend/src/app/components/mempool-block-overview/mempool-block-overview.component.ts b/frontend/src/app/components/mempool-block-overview/mempool-block-overview.component.ts index 3cea7e123..2c564882e 100644 --- a/frontend/src/app/components/mempool-block-overview/mempool-block-overview.component.ts +++ b/frontend/src/app/components/mempool-block-overview/mempool-block-overview.component.ts @@ -144,7 +144,7 @@ export class MempoolBlockOverviewComponent implements OnInit, OnDestroy, OnChang if (blockMined) { this.blockGraph.update(delta.added, delta.removed, delta.changed || [], blockMined ? this.chainDirection : this.poolDirection, blockMined); } else { - this.blockGraph.queueUpdate(delta.added, delta.removed, delta.changed || [], this.poolDirection); + this.blockGraph.deferredUpdate(delta.added, delta.removed, delta.changed || [], this.poolDirection); } }