Browse Source

Limit stats intervals to the history we have available

fix-133-memory-crash
Nadav Ivgi 6 years ago
parent
commit
7f235c831d
No known key found for this signature in database GPG Key ID: 81F6104CD0F150FC
  1. 8
      routes/baseActionsRouter.js

8
routes/baseActionsRouter.js

@ -48,8 +48,12 @@ router.get("/", function(req, res) {
res.locals.getblockchaininfo = getblockchaininfo; res.locals.getblockchaininfo = getblockchaininfo;
if (getblockchaininfo.chain !== 'regtest') { if (getblockchaininfo.chain !== 'regtest') {
var chainTxStatsIntervals = [ 144, 144 * 7, 144 * 30, 144 * 365 ]; var chainTxStatsIntervals = [ 144, 144 * 7, 144 * 30, 144 * 365]
res.locals.chainTxStatsLabels = [ "24 hours", "1 week", "1 month", "1 year", "All time" ]; .filter(numBlocks => numBlocks < getblockchaininfo.blocks);
res.locals.chainTxStatsLabels = [ "24 hours", "1 week", "1 month", "1 year" ]
.slice(0, chainTxStatsIntervals.length)
.concat("All time");
for (var i = 0; i < chainTxStatsIntervals.length; i++) { for (var i = 0; i < chainTxStatsIntervals.length; i++) {
promises.push(coreApi.getChainTxStats(chainTxStatsIntervals[i])); promises.push(coreApi.getChainTxStats(chainTxStatsIntervals[i]));
} }

Loading…
Cancel
Save