Tx audit tags handle coinbase

This commit is contained in:
Mononaut 2024-03-08 15:21:37 +00:00
parent c17b77fe31
commit 7af185a919
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 12 additions and 8 deletions

View File

@ -78,7 +78,8 @@
{{ pool.name }}
</a>
<ng-container *ngIf="auditStatus">
<span *ngIf="auditStatus.expected; else seen" class="badge badge-success mr-1" i18n-ngbTooltip="Expected in block tooltip" ngbTooltip="This transaction was projected to be included in the block" placement="bottom" i18n="tx-features.tag.expected|Expected in Block">Expected in Block</span>
<span *ngIf="auditStatus.coinbase; else expected" class="badge badge-primary mr-1" i18n="tx-features.tag.coinbase|Coinbase">Coinbase</span>
<ng-template #expected><span *ngIf="auditStatus.expected; else seen" class="badge badge-success mr-1" i18n-ngbTooltip="Expected in block tooltip" ngbTooltip="This transaction was projected to be included in the block" placement="bottom" i18n="tx-features.tag.expected|Expected in Block">Expected in Block</span></ng-template>
<ng-template #seen><span *ngIf="auditStatus.seen; else notSeen" class="badge badge-success mr-1" i18n-ngbTooltip="Seen in mempool tooltip" ngbTooltip="This transaction was seen in the mempool prior to mining" placement="bottom" i18n="tx-features.tag.seen|Seen in Mempool">Seen in Mempool</span></ng-template>
<ng-template #notSeen><span class="badge badge-warning mr-1" i18n-ngbTooltip="Not seen in mempool tooltip" ngbTooltip="This transaction was missing from our mempool prior to mining" placement="bottom" i18n="tx-features.tag.not-seen|Not seen in Mempool">Not seen in Mempool</span></ng-template>
<span *ngIf="auditStatus.added" class="badge badge-primary mr-1" i18n-ngbTooltip="Added transaction tooltip" ngbTooltip="This transaction may have been added or prioritized out-of-band" placement="bottom" i18n="tx-features.tag.added|Added">Added</span>

View File

@ -36,12 +36,13 @@ interface Pool {
}
interface AuditStatus {
seen: boolean;
expected: boolean;
added: boolean;
seen?: boolean;
expected?: boolean;
added?: boolean;
delayed?: number;
accelerated: boolean;
conflict: boolean;
accelerated?: boolean;
conflict?: boolean;
coinbase?: boolean;
}
@Component({
@ -296,6 +297,8 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
switchMap(({ hash, height, txid }) => {
const foundBlock = this.cacheService.getCachedBlock(height) || null;
const auditAvailable = this.isAuditAvailable(height);
const isCoinbase = this.tx.vin.some(v => v.is_coinbase);
const fetchAudit = auditAvailable && !isCoinbase;
return combineLatest([
foundBlock ? of(foundBlock.extras.pool) : this.apiService.getBlock$(hash).pipe(
map(block => {
@ -305,7 +308,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
return of(null);
})
),
auditAvailable ? this.apiService.getBlockAudit$(hash).pipe(
fetchAudit ? this.apiService.getBlockAudit$(hash).pipe(
map(audit => {
const isAdded = audit.addedTxs.includes(txid);
const isAccelerated = audit.acceleratedTxs.includes(txid);
@ -322,7 +325,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
catchError(() => {
return of(null);
})
) : of(null)
) : of(isCoinbase ? { coinbase: true } : null)
]);
}),
catchError(() => {