Avoid fetching full audit on tx page
This commit is contained in:
@@ -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` +
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user