Show current network hashrate and difficulty even if indexing is in progress

This commit is contained in:
nymkappa 2022-05-02 17:39:03 +09:00
parent 1f4cf1710a
commit 3972e7b8f0
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 4 additions and 11 deletions

View File

@ -630,7 +630,8 @@ class Routes {
res.json({ res.json({
hashrates: hashrates, hashrates: hashrates,
difficulty: difficulty, difficulty: difficulty,
currentHashrate: await bitcoinClient.getNetworkHashPs() 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);

View File

@ -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.currentHashrate currentHashrate: data.currentHashrate,
}; };
}), }),
retryWhen((errors) => errors.pipe(
delay(60000)
))
); );
}), }),
share() share()