Batch esplora outspends requests
This commit is contained in:
@@ -75,7 +75,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
for (let i = 0; i < txIds.length; i += 50) {
|
||||
batches.push(txIds.slice(i, i + 50));
|
||||
}
|
||||
return forkJoin(batches.map(batch => { return this.apiService.cachedRequest(this.apiService.getOutspendsBatched$, 250, batch); }));
|
||||
return forkJoin(batches.map(batch => this.electrsApiService.getOutspendsBatched$(batch)));
|
||||
} else {
|
||||
return of([]);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ApiService } from '../../services/api.service';
|
||||
import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe';
|
||||
import { AssetsService } from '../../services/assets.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { ElectrsApiService } from '../../services/electrs-api.service';
|
||||
|
||||
interface SvgLine {
|
||||
path: string;
|
||||
@@ -100,7 +101,7 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges {
|
||||
private router: Router,
|
||||
private relativeUrlPipe: RelativeUrlPipe,
|
||||
private stateService: StateService,
|
||||
private apiService: ApiService,
|
||||
private electrsApiService: ElectrsApiService,
|
||||
private assetsService: AssetsService,
|
||||
@Inject(LOCALE_ID) private locale: string,
|
||||
) {
|
||||
@@ -123,7 +124,7 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges {
|
||||
.pipe(
|
||||
switchMap((txid) => {
|
||||
if (!this.cached) {
|
||||
return this.apiService.cachedRequest(this.apiService.getOutspendsBatched$, 250, [txid]);
|
||||
return this.electrsApiService.getOutspendsBatched$([txid]);
|
||||
} else {
|
||||
return of(null);
|
||||
}
|
||||
|
||||
@@ -138,14 +138,6 @@ export class ApiService {
|
||||
return this.httpClient.get<number[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/transaction-times', { params });
|
||||
}
|
||||
|
||||
getOutspendsBatched$(txIds: string[]): Observable<Outspend[][]> {
|
||||
let params = new HttpParams();
|
||||
txIds.forEach((txId: string) => {
|
||||
params = params.append('txId[]', txId);
|
||||
});
|
||||
return this.httpClient.get<Outspend[][]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/outspends', { params });
|
||||
}
|
||||
|
||||
getAboutPageProfiles$(): Observable<any[]> {
|
||||
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/services/sponsors');
|
||||
}
|
||||
|
||||
@@ -54,6 +54,12 @@ export class ElectrsApiService {
|
||||
return this.httpClient.get<Outspend[]>(this.apiBaseUrl + this.apiBasePath + '/api/tx/' + hash + '/outspends');
|
||||
}
|
||||
|
||||
getOutspendsBatched$(txids: string[]): Observable<Outspend[][]> {
|
||||
let params = new HttpParams();
|
||||
params = params.append('txids', txids.join(','));
|
||||
return this.httpClient.get<Outspend[][]>(this.apiBaseUrl + this.apiBasePath + '/api/txs/outspends', { params });
|
||||
}
|
||||
|
||||
getBlockTransactions$(hash: string, index: number = 0): Observable<Transaction[]> {
|
||||
return this.httpClient.get<Transaction[]>(this.apiBaseUrl + this.apiBasePath + '/api/block/' + hash + '/txs/' + index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user