From 67761230e30b2840d06f8a436d443a9b78d419da Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 20 Jul 2024 15:24:56 +0000 Subject: [PATCH] frontend support for v1 block audits --- .../src/app/components/block/block.component.ts | 15 ++++++++++++--- .../transaction/transaction.component.ts | 5 +++-- frontend/src/app/interfaces/node-api.interface.ts | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 01702487f..1b5e25ec2 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -521,6 +521,7 @@ export class BlockComponent implements OnInit, OnDestroy { if (transactions && blockAudit) { const inTemplate = {}; const inBlock = {}; + const isUnseen = {}; const isAdded = {}; const isPrioritized = {}; const isCensored = {}; @@ -543,6 +544,9 @@ export class BlockComponent implements OnInit, OnDestroy { for (const tx of transactions) { inBlock[tx.txid] = true; } + for (const txid of blockAudit.unseenTxs || []) { + isUnseen[txid] = true; + } for (const txid of blockAudit.addedTxs) { isAdded[txid] = true; } @@ -592,18 +596,23 @@ export class BlockComponent implements OnInit, OnDestroy { tx.status = 'accelerated'; } } - for (const [index, tx] of transactions.entries()) { + let anySeen = false; + for (let index = transactions.length - 1; index >= 0; index--) { + const tx = transactions[index]; tx.context = 'actual'; if (index === 0) { tx.status = null; - } else if (isAdded[tx.txid]) { - tx.status = 'added'; } else if (isPrioritized[tx.txid]) { tx.status = 'prioritized'; + } else if (isAdded[tx.txid] && (blockAudit.version === 0 || isUnseen[tx.txid])) { + tx.status = 'added'; } else if (inTemplate[tx.txid]) { + anySeen = true; tx.status = 'found'; } else if (isRbf[tx.txid]) { tx.status = 'rbf'; + } else if (isUnseen[tx.txid] && anySeen) { + tx.status = 'added'; } else { tx.status = 'selected'; isSelected[tx.txid] = true; diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index d6ac58436..aeed03b2c 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -411,10 +411,11 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { const isConflict = audit.fullrbfTxs.includes(txid); const isExpected = audit.template.some(tx => tx.txid === txid); const firstSeen = audit.template.find(tx => tx.txid === txid)?.time; + const wasSeen = audit.version === 1 ? !audit.unseenTxs.includes(txid) : (isExpected || isPrioritized || isAccelerated); return { - seen: isExpected || isPrioritized || isAccelerated, + seen: wasSeen, expected: isExpected, - added: isAdded, + added: isAdded && (audit.version === 0 || !wasSeen), prioritized: isPrioritized, conflict: isConflict, accelerated: isAccelerated, diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 077bfa775..936f635de 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -211,6 +211,8 @@ export interface BlockExtended extends Block { } export interface BlockAudit extends BlockExtended { + version: number, + unseenTxs?: string[], missingTxs: string[], addedTxs: string[], prioritizedTxs: string[],