Add previous adjustment retarget. (#655)
* Add previous adjustment retarget. * Fix green color. Add + symbol to difficulty change. * Add previousRetarget to websocket. * Add previous retarget.
This commit is contained in:
parent
f6a889298c
commit
cd8e308870
@ -215,8 +215,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<h5 class="card-title" i18n="difficulty-box.estimate">Estimate</h5>
|
<h5 class="card-title" i18n="difficulty-box.estimate">Estimate</h5>
|
||||||
<div class="card-text" [ngStyle]="{'color': epochData.colorAdjustments}">{{ epochData.change | number: '1.2-2' }} <span class="symbol">%</span></div>
|
<div class="card-text" [ngStyle]="{'color': epochData.colorAdjustments}">{{epochData.change > 0 ? '+' : ''}}{{ epochData.change | number: '1.2-2' }} <span class="symbol">%</span></div>
|
||||||
<div class="symbol" i18n="difficulty-box.mins-per-block">~{{ epochData.timeAvg }} mins per block</div>
|
<div class="symbol"><span i18n="difficulty-box.previous">Previous</span>: {{epochData.previousRetarget > 0 ? '+' : ''}}{{ epochData.previousRetarget | number: '1.2-2' }} %</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<h5 class="card-title" i18n="difficulty-box.current-period">Current Period</h5>
|
<h5 class="card-title" i18n="difficulty-box.current-period">Current Period</h5>
|
||||||
|
@ -19,8 +19,6 @@ interface MempoolBlocksData {
|
|||||||
|
|
||||||
interface EpochProgress {
|
interface EpochProgress {
|
||||||
base: string;
|
base: string;
|
||||||
green: string;
|
|
||||||
red: string;
|
|
||||||
change: number;
|
change: number;
|
||||||
progress: string;
|
progress: string;
|
||||||
remainingBlocks: number;
|
remainingBlocks: number;
|
||||||
@ -28,6 +26,7 @@ interface EpochProgress {
|
|||||||
colorAdjustments: string;
|
colorAdjustments: string;
|
||||||
timeAvg: string;
|
timeAvg: string;
|
||||||
remainingTime: number;
|
remainingTime: number;
|
||||||
|
previousRetarget: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MempoolInfoData {
|
interface MempoolInfoData {
|
||||||
@ -118,9 +117,10 @@ export class DashboardComponent implements OnInit {
|
|||||||
.pipe(
|
.pipe(
|
||||||
switchMap(() => combineLatest([
|
switchMap(() => combineLatest([
|
||||||
this.stateService.blocks$.pipe(map(([block]) => block)),
|
this.stateService.blocks$.pipe(map(([block]) => block)),
|
||||||
this.stateService.lastDifficultyAdjustment$
|
this.stateService.lastDifficultyAdjustment$,
|
||||||
|
this.stateService.previousRetarget$
|
||||||
])),
|
])),
|
||||||
map(([block, DATime]) => {
|
map(([block, DATime, previousRetarget]) => {
|
||||||
const now = new Date().getTime() / 1000;
|
const now = new Date().getTime() / 1000;
|
||||||
const diff = now - DATime;
|
const diff = now - DATime;
|
||||||
const blocksInEpoch = block.height % 2016;
|
const blocksInEpoch = block.height % 2016;
|
||||||
@ -131,15 +131,11 @@ export class DashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let base = 0;
|
let base = 0;
|
||||||
let green = 0;
|
|
||||||
let red = 0;
|
|
||||||
|
|
||||||
if (blocksInEpoch >= estimatedBlocks) {
|
if (blocksInEpoch >= estimatedBlocks) {
|
||||||
base = estimatedBlocks / 2016 * 100;
|
base = estimatedBlocks / 2016 * 100;
|
||||||
green = (blocksInEpoch - estimatedBlocks) / 2016 * 100;
|
|
||||||
} else {
|
} else {
|
||||||
base = blocksInEpoch / 2016 * 100;
|
base = blocksInEpoch / 2016 * 100;
|
||||||
red = Math.min((estimatedBlocks - blocksInEpoch) / 2016 * 100, 100 - base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let colorAdjustments = '#dc3545';
|
let colorAdjustments = '#dc3545';
|
||||||
@ -162,8 +158,6 @@ export class DashboardComponent implements OnInit {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
base: base + '%',
|
base: base + '%',
|
||||||
green: green + '%',
|
|
||||||
red: red + '%',
|
|
||||||
change: difficultyChange,
|
change: difficultyChange,
|
||||||
progress: base.toFixed(2),
|
progress: base.toFixed(2),
|
||||||
remainingBlocks,
|
remainingBlocks,
|
||||||
@ -171,11 +165,13 @@ export class DashboardComponent implements OnInit {
|
|||||||
colorAdjustments,
|
colorAdjustments,
|
||||||
blocksInEpoch,
|
blocksInEpoch,
|
||||||
newDifficultyHeight: block.height + remainingBlocks,
|
newDifficultyHeight: block.height + remainingBlocks,
|
||||||
remainingTime: remainingBlocsMilliseconds + nowMilliseconds
|
remainingTime: remainingBlocsMilliseconds + nowMilliseconds,
|
||||||
|
previousRetarget
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
this.mempoolBlocksData$ = this.stateService.mempoolBlocks$
|
this.mempoolBlocksData$ = this.stateService.mempoolBlocks$
|
||||||
.pipe(
|
.pipe(
|
||||||
map((mempoolBlocks) => {
|
map((mempoolBlocks) => {
|
||||||
|
@ -25,3 +25,12 @@ export interface CpfpInfo {
|
|||||||
ancestors: Ancestor[];
|
ancestors: Ancestor[];
|
||||||
bestDescendant: BestDescendant | null;
|
bestDescendant: BestDescendant | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DifficultyAdjustment {
|
||||||
|
difficultyChange: number;
|
||||||
|
estimatedRetargetDate: number;
|
||||||
|
previousRetarget: number;
|
||||||
|
progressPercent: number;
|
||||||
|
remainingBlocks: number;
|
||||||
|
remainingTime: number;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
import { CpfpInfo, OptimizedMempoolStats } from '../interfaces/node-api.interface';
|
import { CpfpInfo, OptimizedMempoolStats, DifficultyAdjustment } from '../interfaces/node-api.interface';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { StateService } from './state.service';
|
import { StateService } from './state.service';
|
||||||
import { WebsocketResponse } from '../interfaces/websocket.interface';
|
import { WebsocketResponse } from '../interfaces/websocket.interface';
|
||||||
@ -92,4 +92,8 @@ export class ApiService {
|
|||||||
getCpfpinfo$(txid: string): Observable<CpfpInfo> {
|
getCpfpinfo$(txid: string): Observable<CpfpInfo> {
|
||||||
return this.httpClient.get<CpfpInfo>(this.apiBaseUrl + this.apiBasePath + '/api/v1/cpfp/' + txid);
|
return this.httpClient.get<CpfpInfo>(this.apiBaseUrl + this.apiBasePath + '/api/v1/cpfp/' + txid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDifficultyAdjustment$(): Observable<DifficultyAdjustment> {
|
||||||
|
return this.httpClient.get<DifficultyAdjustment>(this.apiBaseUrl + this.apiBasePath + '/api/v1/difficulty-adjustment');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ export class StateService {
|
|||||||
isLoadingWebSocket$ = new ReplaySubject<boolean>(1);
|
isLoadingWebSocket$ = new ReplaySubject<boolean>(1);
|
||||||
vbytesPerSecond$ = new ReplaySubject<number>(1);
|
vbytesPerSecond$ = new ReplaySubject<number>(1);
|
||||||
lastDifficultyAdjustment$ = new ReplaySubject<number>(1);
|
lastDifficultyAdjustment$ = new ReplaySubject<number>(1);
|
||||||
|
previousRetarget$ = new ReplaySubject<number>(1);
|
||||||
backendInfo$ = new ReplaySubject<IBackendInfo>(1);
|
backendInfo$ = new ReplaySubject<IBackendInfo>(1);
|
||||||
loadingIndicators$ = new ReplaySubject<ILoadingIndicators>(1);
|
loadingIndicators$ = new ReplaySubject<ILoadingIndicators>(1);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ export class WebsocketService {
|
|||||||
this.network = this.stateService.network === 'bisq' && !this.stateService.env.BISQ_SEPARATE_BACKEND ? '' : this.stateService.network;
|
this.network = this.stateService.network === 'bisq' && !this.stateService.env.BISQ_SEPARATE_BACKEND ? '' : this.stateService.network;
|
||||||
this.websocketSubject = webSocket<WebsocketResponse>(this.webSocketUrl.replace('{network}', this.network ? '/' + this.network : ''));
|
this.websocketSubject = webSocket<WebsocketResponse>(this.webSocketUrl.replace('{network}', this.network ? '/' + this.network : ''));
|
||||||
|
|
||||||
const theInitData = this.transferState.get(initData, null);
|
const theInitData = this.transferState.get<any>(initData, null);
|
||||||
if (theInitData) {
|
if (theInitData) {
|
||||||
this.handleResponse(theInitData.body);
|
this.handleResponse(theInitData.body);
|
||||||
this.startSubscription(false, true);
|
this.startSubscription(false, true);
|
||||||
@ -290,6 +290,10 @@ export class WebsocketService {
|
|||||||
this.stateService.lastDifficultyAdjustment$.next(response.lastDifficultyAdjustment);
|
this.stateService.lastDifficultyAdjustment$.next(response.lastDifficultyAdjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.previousRetarget !== undefined) {
|
||||||
|
this.stateService.previousRetarget$.next(response.previousRetarget);
|
||||||
|
}
|
||||||
|
|
||||||
if (response['git-commit']) {
|
if (response['git-commit']) {
|
||||||
this.stateService.backendInfo$.next(response['git-commit']);
|
this.stateService.backendInfo$.next(response['git-commit']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user