Bugfix: Dashboard - Difficulty adjustment component. (#663)

* Add color to previous retarget.
Add absolute number pipe.
Change plus and minus signs to fa icons.
Change Fee Estimate title to Transactions Fees.
Set min and max difficulty adjustments.

* Add projectID to cypress conf.

* Change icon to fa-caret.

* Remove unecessary icons.
This commit is contained in:
Miguel Medeiros
2021-07-26 16:00:40 -03:00
committed by GitHub
parent 60d8697b09
commit 751c7d6e69
8 changed files with 86 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ interface EpochProgress {
remainingBlocks: number;
newDifficultyHeight: number;
colorAdjustments: string;
colorPreviousAdjustments: string;
timeAvg: string;
remainingTime: number;
previousRetarget: number;
@@ -143,19 +144,41 @@ export class DashboardComponent implements OnInit {
colorAdjustments = '#299435';
}
let colorPreviousAdjustments = '#dc3545';
if(previousRetarget){
if (previousRetarget >= 0) {
colorPreviousAdjustments = '#299435';
}
if (previousRetarget === 0) {
colorPreviousAdjustments = '#ffffff66';
}
}else{
colorPreviousAdjustments = '#ffffff66';
}
const timeAvgDiff = difficultyChange * 0.1;
let timeAvgMins = 10;
if (timeAvgDiff > 0 ){
timeAvgMins -= Math.abs(timeAvgDiff);
} else {
timeAvgMins += Math.abs(timeAvgDiff);
if(timeAvgDiff > timeAvgDiff){
if (timeAvgDiff > 0){
timeAvgMins -= Math.abs(timeAvgDiff);
} else {
timeAvgMins += Math.abs(timeAvgDiff);
}
}
const remainingBlocks = 2016 - blocksInEpoch;
const nowMilliseconds = now * 1000;
const timeAvgMilliseconds = timeAvgMins * 60 * 1000;
const remainingBlocsMilliseconds = remainingBlocks * timeAvgMilliseconds;
if(difficultyChange > 300) {
difficultyChange = 300;
}
if(difficultyChange < -75){
difficultyChange = -75;
}
return {
base: base + '%',
change: difficultyChange,
@@ -163,10 +186,11 @@ export class DashboardComponent implements OnInit {
remainingBlocks,
timeAvg: timeAvgMins.toFixed(0),
colorAdjustments,
colorPreviousAdjustments,
blocksInEpoch,
newDifficultyHeight: block.height + remainingBlocks,
remainingTime: remainingBlocsMilliseconds + nowMilliseconds,
previousRetarget
previousRetarget: previousRetarget ? previousRetarget : 0
};
})
);