differentiate censored/missing txs in block audit

This commit is contained in:
Mononaut 2022-10-19 00:23:45 +00:00
parent e2e50ac6bf
commit d86f045150
No known key found for this signature in database
GPG Key ID: 61B952CAF4838F94
5 changed files with 63 additions and 24 deletions

View File

@ -65,24 +65,48 @@ export class BlockAuditComponent implements OnInit, AfterViewInit, OnDestroy {
.pipe( .pipe(
map((response) => { map((response) => {
const blockAudit = response.body; const blockAudit = response.body;
for (let i = 0; i < blockAudit.template.length; ++i) { const inTemplate = {};
if (blockAudit.missingTxs.includes(blockAudit.template[i].txid)) { const inBlock = {};
blockAudit.template[i].status = 'missing'; const isAdded = {};
} else if (blockAudit.addedTxs.includes(blockAudit.template[i].txid)) { const isCensored = {};
blockAudit.template[i].status = 'added'; const isMissing = {};
const isSelected = {};
for (const tx of blockAudit.template) {
inTemplate[tx.txid] = true;
}
for (const tx of blockAudit.transactions) {
inBlock[tx.txid] = true;
}
for (const txid of blockAudit.addedTxs) {
isAdded[txid] = true;
}
for (const txid of blockAudit.missingTxs) {
isCensored[txid] = true;
}
// set transaction statuses
for (const tx of blockAudit.template) {
if (isCensored[tx.txid]) {
tx.status = 'censored';
} else if (inBlock[tx.txid]) {
tx.status = 'found';
} else { } else {
blockAudit.template[i].status = 'found'; tx.status = 'missing';
isMissing[tx.txid] = true;
} }
} }
for (let i = 0; i < blockAudit.transactions.length; ++i) { for (const [index, tx] of blockAudit.transactions.entries()) {
if (blockAudit.missingTxs.includes(blockAudit.transactions[i].txid)) { if (isAdded[tx.txid]) {
blockAudit.transactions[i].status = 'missing'; tx.status = 'added';
} else if (blockAudit.addedTxs.includes(blockAudit.transactions[i].txid)) { } else if (index === 0 || inTemplate[tx.txid]) {
blockAudit.transactions[i].status = 'added'; tx.status = 'found';
} else { } else {
blockAudit.transactions[i].status = 'found'; tx.status = 'selected';
isSelected[tx.txid] = true;
} }
} }
for (const tx of blockAudit.transactions) {
inBlock[tx.txid] = true;
}
return blockAudit; return blockAudit;
}), }),
tap((blockAudit) => { tap((blockAudit) => {

View File

@ -25,7 +25,7 @@ export default class TxView implements TransactionStripped {
vsize: number; vsize: number;
value: number; value: number;
feerate: number; feerate: number;
status?: 'found' | 'missing' | 'added'; status?: 'found' | 'missing' | 'added' | 'censored' | 'selected';
initialised: boolean; initialised: boolean;
vertexArray: FastVertexArray; vertexArray: FastVertexArray;
@ -142,16 +142,21 @@ export default class TxView implements TransactionStripped {
} }
getColor(): Color { getColor(): Color {
// Block audit
if (this.status === 'missing') {
return hexToColor('039BE5');
} else if (this.status === 'added') {
return hexToColor('D81B60');
}
// Block component
const feeLevelIndex = feeLevels.findIndex((feeLvl) => Math.max(1, this.feerate) < feeLvl) - 1; const feeLevelIndex = feeLevels.findIndex((feeLvl) => Math.max(1, this.feerate) < feeLvl) - 1;
return hexToColor(mempoolFeeColors[feeLevelIndex] || mempoolFeeColors[mempoolFeeColors.length - 1]); const feeLevelColor = hexToColor(mempoolFeeColors[feeLevelIndex] || mempoolFeeColors[mempoolFeeColors.length - 1]);
// Block audit
switch(this.status) {
case 'censored':
return hexToColor('D81BC2');
case 'missing':
return hexToColor('8C1BD8');
case 'added':
return hexToColor('03E1E5');
case 'selected':
return hexToColor('039BE5');
default:
return feeLevelColor;
}
} }
} }

View File

@ -32,6 +32,16 @@
<td class="td-width" i18n="transaction.vsize|Transaction Virtual Size">Virtual size</td> <td class="td-width" i18n="transaction.vsize|Transaction Virtual Size">Virtual size</td>
<td [innerHTML]="'&lrm;' + (vsize | vbytes: 2)"></td> <td [innerHTML]="'&lrm;' + (vsize | vbytes: 2)"></td>
</tr> </tr>
<tr *ngIf="tx && tx.status && tx.status.length">
<td class="td-width" i18n="transaction.audit-status">Audit status</td>
<ng-container [ngSwitch]="tx?.status">
<td *ngSwitchCase="'found'" i18n="transaction.audit.match">match</td>
<td *ngSwitchCase="'censored'" i18n="transaction.audit.censored">censored</td>
<td *ngSwitchCase="'missing'" i18n="transaction.audit.missing">missing</td>
<td *ngSwitchCase="'added'" i18n="transaction.audit.prioritized">prioritized</td>
<td *ngSwitchCase="'selected'" i18n="transaction.audit.unexpected">unexpected</td>
</ng-container>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -141,7 +141,7 @@ export interface TransactionStripped {
fee: number; fee: number;
vsize: number; vsize: number;
value: number; value: number;
status?: 'found' | 'missing' | 'added'; status?: 'found' | 'missing' | 'added' | 'censored' | 'selected';
} }
export interface RewardStats { export interface RewardStats {

View File

@ -70,7 +70,7 @@ export interface TransactionStripped {
fee: number; fee: number;
vsize: number; vsize: number;
value: number; value: number;
status?: 'found' | 'missing' | 'added'; status?: 'found' | 'missing' | 'added' | 'censored' | 'selected';
} }
export interface IBackendInfo { export interface IBackendInfo {