2024-03-20 09:57:05 +00:00
|
|
|
import { AfterViewInit, ChangeDetectionStrategy, Component, HostListener, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
|
2024-02-13 00:39:34 +01:00
|
|
|
import { combineLatest, EMPTY, fromEvent, interval, merge, Observable, of, Subject, Subscription, timer } from 'rxjs';
|
2024-02-08 18:32:07 +01:00
|
|
|
import { catchError, delayWhen, distinctUntilChanged, filter, map, scan, share, shareReplay, startWith, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators';
|
2024-04-01 08:07:09 +00:00
|
|
|
import { AuditStatus, BlockExtended, CurrentPegs, FederationAddress, FederationUtxo, OptimizedMempoolStats, PegsVolume, RecentPeg, TransactionStripped } from '../interfaces/node-api.interface';
|
|
|
|
import { MempoolInfo, ReplacementInfo } from '../interfaces/websocket.interface';
|
2020-09-26 22:46:26 +07:00
|
|
|
import { ApiService } from '../services/api.service';
|
2020-09-21 19:41:12 +07:00
|
|
|
import { StateService } from '../services/state.service';
|
2020-09-26 22:46:26 +07:00
|
|
|
import { WebsocketService } from '../services/websocket.service';
|
2020-09-28 16:32:48 +07:00
|
|
|
import { SeoService } from '../services/seo.service';
|
2024-02-08 17:44:32 +00:00
|
|
|
import { ActiveFilter, FilterMode, toFlags } from '../shared/filters.utils';
|
2024-03-20 09:57:05 +00:00
|
|
|
import { detectWebGL } from '../shared/graphs.utils';
|
2020-09-21 19:41:12 +07:00
|
|
|
|
|
|
|
interface MempoolBlocksData {
|
|
|
|
blocks: number;
|
|
|
|
size: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface MempoolInfoData {
|
|
|
|
memPoolInfo: MempoolInfo;
|
|
|
|
vBytesPerSecond: number;
|
|
|
|
progressWidth: string;
|
2021-08-21 01:46:28 -03:00
|
|
|
progressColor: string;
|
2020-09-21 19:41:12 +07:00
|
|
|
}
|
|
|
|
|
2020-09-26 22:46:26 +07:00
|
|
|
interface MempoolStatsData {
|
|
|
|
mempool: OptimizedMempoolStats[];
|
|
|
|
weightPerSecond: any;
|
|
|
|
}
|
|
|
|
|
2020-09-21 19:41:12 +07:00
|
|
|
@Component({
|
|
|
|
selector: 'app-dashboard',
|
|
|
|
templateUrl: './dashboard.component.html',
|
|
|
|
styleUrls: ['./dashboard.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
2023-07-25 15:03:39 +09:00
|
|
|
export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
2020-09-21 19:41:12 +07:00
|
|
|
network$: Observable<string>;
|
|
|
|
mempoolBlocksData$: Observable<MempoolBlocksData>;
|
|
|
|
mempoolInfoData$: Observable<MempoolInfoData>;
|
2021-01-05 18:57:06 +07:00
|
|
|
mempoolLoadingStatus$: Observable<number>;
|
2020-09-21 19:41:12 +07:00
|
|
|
vBytesPerSecondLimit = 1667;
|
2020-09-26 02:11:30 +07:00
|
|
|
transactions$: Observable<TransactionStripped[]>;
|
2023-07-19 12:09:46 +09:00
|
|
|
blocks$: Observable<BlockExtended[]>;
|
2023-07-14 11:52:07 +09:00
|
|
|
replacements$: Observable<ReplacementInfo[]>;
|
2020-09-26 02:11:30 +07:00
|
|
|
latestBlockHeight: number;
|
2020-09-26 22:46:26 +07:00
|
|
|
mempoolTransactionsWeightPerSecondData: any;
|
|
|
|
mempoolStats$: Observable<MempoolStatsData>;
|
|
|
|
transactionsWeightPerSecondOptions: any;
|
2021-07-26 20:47:08 -03:00
|
|
|
isLoadingWebSocket$: Observable<boolean>;
|
2021-09-25 03:13:07 +04:00
|
|
|
liquidPegsMonth$: Observable<any>;
|
2024-01-21 13:19:02 +01:00
|
|
|
currentPeg$: Observable<CurrentPegs>;
|
|
|
|
auditStatus$: Observable<AuditStatus>;
|
2024-01-23 09:57:26 +01:00
|
|
|
auditUpdated$: Observable<boolean>;
|
2024-01-21 13:19:02 +01:00
|
|
|
liquidReservesMonth$: Observable<any>;
|
|
|
|
currentReserves$: Observable<CurrentPegs>;
|
2024-02-13 00:39:34 +01:00
|
|
|
recentPegsList$: Observable<RecentPeg[]>;
|
|
|
|
pegsVolume$: Observable<PegsVolume[]>;
|
|
|
|
federationAddresses$: Observable<FederationAddress[]>;
|
|
|
|
federationAddressesNumber$: Observable<number>;
|
|
|
|
federationUtxosNumber$: Observable<number>;
|
2024-02-27 16:39:28 +01:00
|
|
|
expiredUtxos$: Observable<FederationUtxo[]>;
|
|
|
|
emergencySpentUtxosStats$: Observable<any>;
|
2024-01-21 13:19:02 +01:00
|
|
|
fullHistory$: Observable<any>;
|
2024-01-26 20:43:34 +01:00
|
|
|
isLoad: boolean = true;
|
2024-02-08 17:44:32 +00:00
|
|
|
filterSubscription: Subscription;
|
2024-02-07 21:39:39 +00:00
|
|
|
mempoolInfoSubscription: Subscription;
|
2023-02-15 16:22:06 +09:00
|
|
|
currencySubscription: Subscription;
|
|
|
|
currency: string;
|
2024-02-07 21:39:39 +00:00
|
|
|
incomingGraphHeight: number = 300;
|
2024-02-27 16:39:28 +01:00
|
|
|
lbtcPegGraphHeight: number = 360;
|
2024-03-20 09:57:05 +00:00
|
|
|
webGlEnabled = true;
|
2024-01-21 13:19:02 +01:00
|
|
|
private lastPegBlockUpdate: number = 0;
|
2024-01-26 18:52:07 +01:00
|
|
|
private lastPegAmount: string = '';
|
2024-01-21 13:19:02 +01:00
|
|
|
private lastReservesBlockUpdate: number = 0;
|
2020-09-21 19:41:12 +07:00
|
|
|
|
2024-02-08 03:57:11 +00:00
|
|
|
goggleResolution = 82;
|
2024-02-08 17:44:32 +00:00
|
|
|
goggleCycle: { index: number, name: string, mode: FilterMode, filters: string[] }[] = [
|
|
|
|
{ index: 0, name: 'All', mode: 'and', filters: [] },
|
|
|
|
{ index: 1, name: 'Consolidation', mode: 'and', filters: ['consolidation'] },
|
|
|
|
{ index: 2, name: 'Coinjoin', mode: 'and', filters: ['coinjoin'] },
|
2024-02-09 17:42:20 +00:00
|
|
|
{ index: 3, name: 'Data', mode: 'or', filters: ['inscription', 'fake_pubkey', 'op_return'] },
|
2024-02-08 03:57:11 +00:00
|
|
|
];
|
2024-02-08 17:44:32 +00:00
|
|
|
goggleFlags = 0n;
|
|
|
|
goggleMode: FilterMode = 'and';
|
|
|
|
goggleIndex = 0;
|
2024-02-08 03:57:11 +00:00
|
|
|
|
2024-01-27 19:19:14 +01:00
|
|
|
private destroy$ = new Subject();
|
|
|
|
|
2020-09-21 19:41:12 +07:00
|
|
|
constructor(
|
2021-08-05 02:03:52 +03:00
|
|
|
public stateService: StateService,
|
2020-09-26 22:46:26 +07:00
|
|
|
private apiService: ApiService,
|
|
|
|
private websocketService: WebsocketService,
|
2024-03-20 09:57:05 +00:00
|
|
|
private seoService: SeoService,
|
|
|
|
@Inject(PLATFORM_ID) private platformId: Object,
|
|
|
|
) {
|
|
|
|
this.webGlEnabled = this.stateService.isBrowser && detectWebGL();
|
|
|
|
}
|
2020-09-21 19:41:12 +07:00
|
|
|
|
2023-07-25 15:03:39 +09:00
|
|
|
ngAfterViewInit(): void {
|
2023-07-24 11:35:46 +09:00
|
|
|
this.stateService.focusSearchInputDesktop();
|
2023-07-24 10:18:00 +09:00
|
|
|
}
|
|
|
|
|
2023-02-15 16:22:06 +09:00
|
|
|
ngOnDestroy(): void {
|
2024-02-08 17:44:32 +00:00
|
|
|
this.filterSubscription.unsubscribe();
|
2024-02-07 21:39:39 +00:00
|
|
|
this.mempoolInfoSubscription.unsubscribe();
|
2023-02-15 16:22:06 +09:00
|
|
|
this.currencySubscription.unsubscribe();
|
2023-07-14 16:08:57 +09:00
|
|
|
this.websocketService.stopTrackRbfSummary();
|
2024-01-27 19:19:14 +01:00
|
|
|
this.destroy$.next(1);
|
|
|
|
this.destroy$.complete();
|
2023-02-15 16:22:06 +09:00
|
|
|
}
|
|
|
|
|
2020-09-21 19:41:12 +07:00
|
|
|
ngOnInit(): void {
|
2024-02-07 21:39:39 +00:00
|
|
|
this.onResize();
|
2021-07-26 20:47:08 -03:00
|
|
|
this.isLoadingWebSocket$ = this.stateService.isLoadingWebSocket$;
|
2020-09-28 16:32:48 +07:00
|
|
|
this.seoService.resetTitle();
|
2023-08-30 20:26:07 +09:00
|
|
|
this.seoService.resetDescription();
|
2020-09-26 22:46:26 +07:00
|
|
|
this.websocketService.want(['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
|
2023-07-14 16:08:57 +09:00
|
|
|
this.websocketService.startTrackRbfSummary();
|
2020-09-21 19:41:12 +07:00
|
|
|
this.network$ = merge(of(''), this.stateService.networkChanged$);
|
2021-08-21 01:46:28 -03:00
|
|
|
this.mempoolLoadingStatus$ = this.stateService.loadingIndicators$
|
|
|
|
.pipe(
|
|
|
|
map((indicators) => indicators.mempool !== undefined ? indicators.mempool : 100)
|
|
|
|
);
|
2020-09-21 19:41:12 +07:00
|
|
|
|
2024-02-08 17:44:32 +00:00
|
|
|
this.filterSubscription = this.stateService.activeGoggles$.subscribe((active: ActiveFilter) => {
|
|
|
|
const activeFilters = active.filters.sort().join(',');
|
|
|
|
for (const goggle of this.goggleCycle) {
|
|
|
|
if (goggle.mode === active.mode) {
|
|
|
|
const goggleFilters = goggle.filters.sort().join(',');
|
|
|
|
if (goggleFilters === activeFilters) {
|
|
|
|
this.goggleIndex = goggle.index;
|
|
|
|
this.goggleFlags = toFlags(goggle.filters);
|
|
|
|
this.goggleMode = goggle.mode;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.goggleCycle.push({
|
|
|
|
index: this.goggleCycle.length,
|
|
|
|
name: 'Custom',
|
|
|
|
mode: active.mode,
|
|
|
|
filters: active.filters,
|
|
|
|
});
|
|
|
|
this.goggleIndex = this.goggleCycle.length - 1;
|
|
|
|
this.goggleFlags = toFlags(active.filters);
|
|
|
|
this.goggleMode = active.mode;
|
|
|
|
});
|
|
|
|
|
2020-09-21 19:41:12 +07:00
|
|
|
this.mempoolInfoData$ = combineLatest([
|
|
|
|
this.stateService.mempoolInfo$,
|
|
|
|
this.stateService.vbytesPerSecond$
|
2024-02-07 21:39:39 +00:00
|
|
|
]).pipe(
|
|
|
|
map(([mempoolInfo, vbytesPerSecond]) => {
|
|
|
|
const percent = Math.round((Math.min(vbytesPerSecond, this.vBytesPerSecondLimit) / this.vBytesPerSecondLimit) * 100);
|
|
|
|
|
|
|
|
let progressColor = 'bg-success';
|
|
|
|
if (vbytesPerSecond > 1667) {
|
|
|
|
progressColor = 'bg-warning';
|
|
|
|
}
|
|
|
|
if (vbytesPerSecond > 3000) {
|
|
|
|
progressColor = 'bg-danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
const mempoolSizePercentage = (mempoolInfo.usage / mempoolInfo.maxmempool * 100);
|
|
|
|
let mempoolSizeProgress = 'bg-danger';
|
|
|
|
if (mempoolSizePercentage <= 50) {
|
|
|
|
mempoolSizeProgress = 'bg-success';
|
|
|
|
} else if (mempoolSizePercentage <= 75) {
|
|
|
|
mempoolSizeProgress = 'bg-warning';
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
memPoolInfo: mempoolInfo,
|
|
|
|
vBytesPerSecond: vbytesPerSecond,
|
|
|
|
progressWidth: percent + '%',
|
|
|
|
progressColor: progressColor,
|
|
|
|
mempoolSizeProgress: mempoolSizeProgress,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
this.mempoolInfoSubscription = this.mempoolInfoData$.subscribe();
|
2021-08-25 17:18:27 -03:00
|
|
|
|
2020-09-21 19:41:12 +07:00
|
|
|
this.mempoolBlocksData$ = this.stateService.mempoolBlocks$
|
|
|
|
.pipe(
|
|
|
|
map((mempoolBlocks) => {
|
|
|
|
const size = mempoolBlocks.map((m) => m.blockSize).reduce((a, b) => a + b, 0);
|
|
|
|
const vsize = mempoolBlocks.map((m) => m.blockVSize).reduce((a, b) => a + b, 0);
|
|
|
|
|
|
|
|
return {
|
|
|
|
size: size,
|
2021-07-31 17:30:35 +03:00
|
|
|
blocks: Math.ceil(vsize / this.stateService.blockVSize)
|
2020-09-21 19:41:12 +07:00
|
|
|
};
|
|
|
|
})
|
|
|
|
);
|
2020-09-26 02:11:30 +07:00
|
|
|
|
2024-03-15 05:44:20 +00:00
|
|
|
this.transactions$ = this.stateService.transactions$;
|
2020-09-26 22:46:26 +07:00
|
|
|
|
2023-07-19 12:09:46 +09:00
|
|
|
this.blocks$ = this.stateService.blocks$
|
|
|
|
.pipe(
|
|
|
|
tap((blocks) => {
|
|
|
|
this.latestBlockHeight = blocks[0].height;
|
|
|
|
}),
|
|
|
|
switchMap((blocks) => {
|
|
|
|
if (this.stateService.env.MINING_DASHBOARD === true) {
|
|
|
|
for (const block of blocks) {
|
|
|
|
// @ts-ignore: Need to add an extra field for the template
|
|
|
|
block.extras.pool.logo = `/resources/mining-pools/` +
|
2023-07-28 13:45:04 +09:00
|
|
|
block.extras.pool.slug + '.svg';
|
2023-07-19 12:09:46 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return of(blocks.slice(0, 6));
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2023-07-14 16:08:57 +09:00
|
|
|
this.replacements$ = this.stateService.rbfLatestSummary$;
|
2023-07-14 11:52:07 +09:00
|
|
|
|
2021-08-21 01:46:28 -03:00
|
|
|
this.mempoolStats$ = this.stateService.connectionState$
|
|
|
|
.pipe(
|
|
|
|
filter((state) => state === 2),
|
2023-07-29 15:16:28 +09:00
|
|
|
switchMap(() => this.apiService.list2HStatistics$().pipe(
|
|
|
|
catchError((e) => {
|
|
|
|
return of(null);
|
|
|
|
})
|
|
|
|
)),
|
2021-08-21 01:46:28 -03:00
|
|
|
switchMap((mempoolStats) => {
|
|
|
|
return merge(
|
|
|
|
this.stateService.live2Chart$
|
|
|
|
.pipe(
|
|
|
|
scan((acc, stats) => {
|
|
|
|
acc.unshift(stats);
|
|
|
|
acc = acc.slice(0, 120);
|
|
|
|
return acc;
|
2024-03-08 16:47:15 +00:00
|
|
|
}, (mempoolStats || []))
|
2021-08-21 01:46:28 -03:00
|
|
|
),
|
|
|
|
of(mempoolStats)
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
map((mempoolStats) => {
|
2023-07-29 15:16:28 +09:00
|
|
|
if (mempoolStats) {
|
|
|
|
return {
|
|
|
|
mempool: mempoolStats,
|
|
|
|
weightPerSecond: this.handleNewMempoolData(mempoolStats.concat([])),
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-21 01:46:28 -03:00
|
|
|
}),
|
2023-10-25 16:38:05 +00:00
|
|
|
shareReplay(1),
|
2021-08-21 01:46:28 -03:00
|
|
|
);
|
2021-09-25 03:13:07 +04:00
|
|
|
|
2024-02-13 00:39:34 +01:00
|
|
|
if (this.stateService.network === 'liquid') {
|
2024-01-26 20:43:34 +01:00
|
|
|
this.auditStatus$ = this.stateService.blocks$.pipe(
|
2024-01-27 19:19:14 +01:00
|
|
|
takeUntil(this.destroy$),
|
2024-01-26 20:43:34 +01:00
|
|
|
throttleTime(40000),
|
|
|
|
delayWhen(_ => this.isLoad ? timer(0) : timer(2000)),
|
|
|
|
tap(() => this.isLoad = false),
|
|
|
|
switchMap(() => this.apiService.federationAuditSynced$()),
|
2024-01-27 19:19:14 +01:00
|
|
|
shareReplay(1)
|
2024-01-26 20:43:34 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
this.currentPeg$ = this.auditStatus$.pipe(
|
|
|
|
switchMap(_ =>
|
|
|
|
this.apiService.liquidPegs$().pipe(
|
|
|
|
filter((currentPegs) => currentPegs.lastBlockUpdate >= this.lastPegBlockUpdate),
|
|
|
|
tap((currentPegs) => {
|
|
|
|
this.lastPegBlockUpdate = currentPegs.lastBlockUpdate;
|
|
|
|
})
|
2024-01-21 13:19:02 +01:00
|
|
|
)
|
2024-01-26 20:43:34 +01:00
|
|
|
),
|
2024-01-21 13:19:02 +01:00
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
2024-01-26 18:52:07 +01:00
|
|
|
this.auditUpdated$ = combineLatest([
|
|
|
|
this.auditStatus$,
|
|
|
|
this.currentPeg$
|
|
|
|
]).pipe(
|
|
|
|
filter(([auditStatus, _]) => auditStatus.isAuditSynced === true),
|
|
|
|
map(([auditStatus, currentPeg]) => ({
|
|
|
|
lastBlockAudit: auditStatus.lastBlockAudit,
|
|
|
|
currentPegAmount: currentPeg.amount
|
2024-01-26 20:43:34 +01:00
|
|
|
})),
|
2024-01-26 18:52:07 +01:00
|
|
|
switchMap(({ lastBlockAudit, currentPegAmount }) => {
|
|
|
|
const blockAuditCheck = lastBlockAudit > this.lastReservesBlockUpdate;
|
|
|
|
const amountCheck = currentPegAmount !== this.lastPegAmount;
|
|
|
|
this.lastPegAmount = currentPegAmount;
|
|
|
|
return of(blockAuditCheck || amountCheck);
|
2024-01-21 13:19:02 +01:00
|
|
|
}),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
2024-01-23 09:57:26 +01:00
|
|
|
this.currentReserves$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
2024-01-26 18:52:07 +01:00
|
|
|
throttleTime(40000),
|
2024-01-21 13:19:02 +01:00
|
|
|
switchMap(_ =>
|
|
|
|
this.apiService.liquidReserves$().pipe(
|
2024-01-26 18:52:07 +01:00
|
|
|
filter((currentReserves) => currentReserves.lastBlockUpdate >= this.lastReservesBlockUpdate),
|
2024-01-21 13:19:02 +01:00
|
|
|
tap((currentReserves) => {
|
|
|
|
this.lastReservesBlockUpdate = currentReserves.lastBlockUpdate;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
2024-02-13 00:39:34 +01:00
|
|
|
this.recentPegsList$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.recentPegsList$()),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.pegsVolume$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.pegsVolume$()),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.federationAddresses$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.federationAddresses$()),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.federationAddressesNumber$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.federationAddressesNumber$()),
|
|
|
|
map(count => count.address_count),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.federationUtxosNumber$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.federationUtxosNumber$()),
|
|
|
|
map(count => count.utxo_count),
|
|
|
|
share()
|
|
|
|
);
|
2024-02-27 16:39:28 +01:00
|
|
|
|
|
|
|
this.expiredUtxos$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.expiredUtxos$()),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.emergencySpentUtxosStats$ = this.auditUpdated$.pipe(
|
|
|
|
filter(auditUpdated => auditUpdated === true),
|
|
|
|
throttleTime(40000),
|
|
|
|
switchMap(_ => this.apiService.emergencySpentUtxosStats$()),
|
|
|
|
share()
|
|
|
|
);
|
2024-02-13 00:39:34 +01:00
|
|
|
|
|
|
|
this.liquidPegsMonth$ = interval(60 * 60 * 1000)
|
|
|
|
.pipe(
|
|
|
|
startWith(0),
|
|
|
|
switchMap(() => this.apiService.listLiquidPegsMonth$()),
|
|
|
|
map((pegs) => {
|
|
|
|
const labels = pegs.map(stats => stats.date);
|
|
|
|
const series = pegs.map(stats => parseFloat(stats.amount) / 100000000);
|
|
|
|
series.reduce((prev, curr, i) => series[i] = prev + curr, 0);
|
|
|
|
return {
|
|
|
|
series,
|
|
|
|
labels
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
share(),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.liquidReservesMonth$ = interval(60 * 60 * 1000).pipe(
|
|
|
|
startWith(0),
|
|
|
|
switchMap(() => this.apiService.listLiquidReservesMonth$()),
|
|
|
|
map(reserves => {
|
|
|
|
const labels = reserves.map(stats => stats.date);
|
|
|
|
const series = reserves.map(stats => parseFloat(stats.amount) / 100000000);
|
|
|
|
return {
|
|
|
|
series,
|
|
|
|
labels
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
share()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.fullHistory$ = combineLatest([this.liquidPegsMonth$, this.currentPeg$, this.liquidReservesMonth$, this.currentReserves$])
|
2024-01-21 13:19:02 +01:00
|
|
|
.pipe(
|
|
|
|
map(([liquidPegs, currentPeg, liquidReserves, currentReserves]) => {
|
|
|
|
liquidPegs.series[liquidPegs.series.length - 1] = parseFloat(currentPeg.amount) / 100000000;
|
2024-02-13 00:39:34 +01:00
|
|
|
|
2024-01-21 13:19:02 +01:00
|
|
|
if (liquidPegs.series.length === liquidReserves?.series.length) {
|
|
|
|
liquidReserves.series[liquidReserves.series.length - 1] = parseFloat(currentReserves?.amount) / 100000000;
|
|
|
|
} else if (liquidPegs.series.length === liquidReserves?.series.length + 1) {
|
|
|
|
liquidReserves.series.push(parseFloat(currentReserves?.amount) / 100000000);
|
2024-01-23 09:57:26 +01:00
|
|
|
liquidReserves.labels.push(liquidPegs.labels[liquidPegs.labels.length - 1]);
|
2024-01-21 13:19:02 +01:00
|
|
|
} else {
|
|
|
|
liquidReserves = {
|
|
|
|
series: [],
|
|
|
|
labels: []
|
|
|
|
};
|
|
|
|
}
|
2024-02-13 00:39:34 +01:00
|
|
|
|
2024-01-21 13:19:02 +01:00
|
|
|
return {
|
|
|
|
liquidPegs,
|
|
|
|
liquidReserves
|
|
|
|
};
|
2024-01-23 09:57:26 +01:00
|
|
|
}),
|
|
|
|
share()
|
2024-01-21 13:19:02 +01:00
|
|
|
);
|
2021-09-25 03:13:07 +04:00
|
|
|
}
|
2023-02-15 16:22:06 +09:00
|
|
|
|
|
|
|
this.currencySubscription = this.stateService.fiatCurrency$.subscribe((fiat) => {
|
|
|
|
this.currency = fiat;
|
|
|
|
});
|
2020-09-26 22:46:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
handleNewMempoolData(mempoolStats: OptimizedMempoolStats[]) {
|
|
|
|
mempoolStats.reverse();
|
|
|
|
const labels = mempoolStats.map(stats => stats.added);
|
|
|
|
|
|
|
|
return {
|
|
|
|
labels: labels,
|
2021-12-11 10:38:13 +09:00
|
|
|
series: [mempoolStats.map((stats) => [stats.added * 1000, stats.vbytes_per_second])],
|
2020-09-26 22:46:26 +07:00
|
|
|
};
|
2020-09-26 02:11:30 +07:00
|
|
|
}
|
|
|
|
|
2022-02-04 12:51:45 +09:00
|
|
|
trackByBlock(index: number, block: BlockExtended) {
|
2020-09-26 02:11:30 +07:00
|
|
|
return block.height;
|
2020-09-21 19:41:12 +07:00
|
|
|
}
|
2024-02-07 21:39:39 +00:00
|
|
|
|
2024-02-08 18:32:07 +01:00
|
|
|
getArrayFromNumber(num: number): number[] {
|
|
|
|
return Array.from({ length: num }, (_, i) => i + 1);
|
|
|
|
}
|
|
|
|
|
2024-02-08 17:44:32 +00:00
|
|
|
setFilter(index): void {
|
|
|
|
const selected = this.goggleCycle[index];
|
|
|
|
this.stateService.activeGoggles$.next(selected);
|
|
|
|
}
|
2024-02-13 00:39:34 +01:00
|
|
|
|
2024-02-07 21:39:39 +00:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(): void {
|
|
|
|
if (window.innerWidth >= 992) {
|
|
|
|
this.incomingGraphHeight = 300;
|
2024-02-08 03:57:11 +00:00
|
|
|
this.goggleResolution = 82;
|
2024-02-27 16:39:28 +01:00
|
|
|
this.lbtcPegGraphHeight = 360;
|
2024-02-07 21:39:39 +00:00
|
|
|
} else if (window.innerWidth >= 768) {
|
|
|
|
this.incomingGraphHeight = 215;
|
2024-02-08 03:57:11 +00:00
|
|
|
this.goggleResolution = 80;
|
2024-02-27 16:39:28 +01:00
|
|
|
this.lbtcPegGraphHeight = 270;
|
2024-02-07 21:39:39 +00:00
|
|
|
} else {
|
|
|
|
this.incomingGraphHeight = 180;
|
2024-02-08 03:57:11 +00:00
|
|
|
this.goggleResolution = 86;
|
2024-02-27 16:39:28 +01:00
|
|
|
this.lbtcPegGraphHeight = 270;
|
2024-02-07 21:39:39 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-21 19:41:12 +07:00
|
|
|
}
|