Merge pull request #3953 from mempool/mononaut/difficulty-updates

always show latest difficulty on hashrate chart
This commit is contained in:
wiz
2023-07-12 17:33:22 +09:00
committed by GitHub

View File

@@ -109,6 +109,14 @@ export class HashrateChartComponent implements OnInit {
tap((response: any) => {
const data = response.body;
// always include the latest difficulty
if (data.difficulty.length && data.difficulty[data.difficulty.length - 1].difficulty !== data.currentDifficulty) {
data.difficulty.push({
timestamp: Date.now() / 1000,
difficulty: data.currentDifficulty
});
}
// We generate duplicated data point so the tooltip works nicely
const diffFixed = [];
let diffIndex = 1;
@@ -137,6 +145,14 @@ export class HashrateChartComponent implements OnInit {
++diffIndex;
}
while (diffIndex <= data.difficulty.length) {
diffFixed.push({
timestamp: data.difficulty[diffIndex - 1].time,
difficulty: data.difficulty[diffIndex - 1].difficulty
});
diffIndex++;
}
let maResolution = 15;
const hashrateMa = [];
for (let i = maResolution - 1; i < data.hashrates.length; ++i) {