Avoid fetching full audit on tx page

This commit is contained in:
natsoni
2024-07-10 13:13:53 +09:00
parent 2d03ab6346
commit 99ea1ad0a0
9 changed files with 128 additions and 30 deletions

View File

@@ -8,6 +8,7 @@ import { Transaction } from '../interfaces/electrs.interface';
import { Conversion } from './price.service';
import { StorageService } from './storage.service';
import { WebsocketResponse } from '../interfaces/websocket.interface';
import { TxAuditStatus } from '../components/transaction/transaction.component';
@Injectable({
providedIn: 'root'
@@ -374,6 +375,12 @@ export class ApiService {
);
}
getBlockTxAudit$(hash: string, txid: string) : Observable<TxAuditStatus> {
return this.httpClient.get<TxAuditStatus>(
this.apiBaseUrl + this.apiBasePath + `/api/v1/block/${hash}/tx/${txid}/audit`
);
}
getBlockAuditScores$(from: number): Observable<AuditScore[]> {
return this.httpClient.get<AuditScore[]>(
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/audit/scores` +

View File

@@ -20,6 +20,7 @@ export class CacheService {
network: string;
blockHashCache: { [hash: string]: BlockExtended } = {};
blockCache: { [height: number]: BlockExtended } = {};
blockAuditLoaded: { [hash: string]: boolean } = {};
blockLoading: { [height: number]: boolean } = {};
copiesInBlockQueue: { [height: number]: number } = {};
blockPriorities: number[] = [];
@@ -97,6 +98,10 @@ export class CacheService {
}
}
async setBlockAuditLoaded(hash: string) {
this.blockAuditLoaded[hash] = true;
}
// increase the priority of a block, to delay removal
bumpBlockPriority(height) {
this.blockPriorities.push(height);
@@ -124,6 +129,7 @@ export class CacheService {
resetBlockCache() {
this.blockHashCache = {};
this.blockCache = {};
this.blockAuditLoaded = {};
this.blockLoading = {};
this.copiesInBlockQueue = {};
this.blockPriorities = [];
@@ -132,4 +138,8 @@ export class CacheService {
getCachedBlock(height) {
return this.blockCache[height];
}
getBlockAuditLoaded(hash) {
return this.blockAuditLoaded[hash];
}
}