Merge pull request #3953 from mempool/mononaut/difficulty-updates
always show latest difficulty on hashrate chart
This commit is contained in:
commit
243fd5e9dd
@ -109,6 +109,14 @@ export class HashrateChartComponent implements OnInit {
|
|||||||
tap((response: any) => {
|
tap((response: any) => {
|
||||||
const data = response.body;
|
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
|
// We generate duplicated data point so the tooltip works nicely
|
||||||
const diffFixed = [];
|
const diffFixed = [];
|
||||||
let diffIndex = 1;
|
let diffIndex = 1;
|
||||||
@ -137,6 +145,14 @@ export class HashrateChartComponent implements OnInit {
|
|||||||
++diffIndex;
|
++diffIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (diffIndex <= data.difficulty.length) {
|
||||||
|
diffFixed.push({
|
||||||
|
timestamp: data.difficulty[diffIndex - 1].time,
|
||||||
|
difficulty: data.difficulty[diffIndex - 1].difficulty
|
||||||
|
});
|
||||||
|
diffIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
let maResolution = 15;
|
let maResolution = 15;
|
||||||
const hashrateMa = [];
|
const hashrateMa = [];
|
||||||
for (let i = maResolution - 1; i < data.hashrates.length; ++i) {
|
for (let i = maResolution - 1; i < data.hashrates.length; ++i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user