Merge pull request #1592 from mempool/nymkappa/feature/realtime-estimated-hashrate
Show current network hashrate and difficulty using core RPC
This commit is contained in:
commit
f45dc25a08
@ -630,6 +630,8 @@ class Routes {
|
|||||||
res.json({
|
res.json({
|
||||||
hashrates: hashrates,
|
hashrates: hashrates,
|
||||||
difficulty: difficulty,
|
difficulty: difficulty,
|
||||||
|
currentHashrate: await bitcoinClient.getNetworkHashPs(),
|
||||||
|
currentDifficulty: await bitcoinClient.getDifficulty(),
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.status(500).send(e instanceof Error ? e.message : e);
|
res.status(500).send(e instanceof Error ? e.message : e);
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<h5 class="card-title" i18n="mining.hashrate">Hashrate</h5>
|
<h5 class="card-title" i18n="mining.hashrate">Hashrate</h5>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
{{ hashrates.currentHashrate | amountShortener }}
|
{{ hashrates.currentHashrate | amountShortener: 1 : 'H/s' }}
|
||||||
<span class="symbol">hashes/sec</span>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
@ -114,23 +114,15 @@ export class HashrateChartComponent implements OnInit {
|
|||||||
difficulty: diffFixed.map(val => [val.timestamp * 1000, val.difficulty]),
|
difficulty: diffFixed.map(val => [val.timestamp * 1000, val.difficulty]),
|
||||||
});
|
});
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
|
||||||
if (data.hashrates.length === 0) {
|
|
||||||
this.cd.markForCheck();
|
|
||||||
throw new Error();
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
map((response) => {
|
map((response) => {
|
||||||
const data = response.body;
|
const data = response.body;
|
||||||
return {
|
return {
|
||||||
blockCount: parseInt(response.headers.get('x-total-count'), 10),
|
blockCount: parseInt(response.headers.get('x-total-count'), 10),
|
||||||
currentDifficulty: Math.round(data.difficulty[data.difficulty.length - 1].difficulty * 100) / 100,
|
currentDifficulty: data.currentDifficulty,
|
||||||
currentHashrate: data.hashrates[data.hashrates.length - 1].avgHashrate,
|
currentHashrate: data.currentHashrate,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
retryWhen((errors) => errors.pipe(
|
|
||||||
delay(60000)
|
|
||||||
))
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
share()
|
share()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user