From 1675b615d1d9b008be686059707272d5e10a1126 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Sun, 10 Feb 2019 15:01:25 -0500 Subject: [PATCH] Fix #84 - thanks @yuhlau --- routes/baseActionsRouter.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/routes/baseActionsRouter.js b/routes/baseActionsRouter.js index 1a3bc21..f1cf51c 100644 --- a/routes/baseActionsRouter.js +++ b/routes/baseActionsRouter.js @@ -44,15 +44,17 @@ router.get("/", function(req, res) { promises.push(coreApi.getMempoolInfo()); promises.push(coreApi.getMiningInfo()); - var chainTxStatsIntervals = [ 144, 144 * 7, 144 * 30, 144 * 365 ]; - res.locals.chainTxStatsLabels = [ "24 hours", "1 week", "1 month", "1 year", "All time" ]; - for (var i = 0; i < chainTxStatsIntervals.length; i++) { - promises.push(coreApi.getChainTxStats(chainTxStatsIntervals[i])); - } - coreApi.getBlockchainInfo().then(function(getblockchaininfo) { res.locals.getblockchaininfo = getblockchaininfo; + if (getblockchaininfo.chain !== 'regtest') { + var chainTxStatsIntervals = [ 144, 144 * 7, 144 * 30, 144 * 365 ]; + res.locals.chainTxStatsLabels = [ "24 hours", "1 week", "1 month", "1 year", "All time" ]; + for (var i = 0; i < chainTxStatsIntervals.length; i++) { + promises.push(coreApi.getChainTxStats(chainTxStatsIntervals[i])); + } + } + var blockHeights = []; if (getblockchaininfo.blocks) { for (var i = 0; i < 10; i++) { @@ -69,12 +71,14 @@ router.get("/", function(req, res) { res.locals.mempoolInfo = promiseResults[0]; res.locals.miningInfo = promiseResults[1]; - var chainTxStats = []; - for (var i = 0; i < res.locals.chainTxStatsLabels.length; i++) { - chainTxStats.push(promiseResults[i + 2]); - } + if (getblockchaininfo.chain !== 'regtest') { + var chainTxStats = []; + for (var i = 0; i < res.locals.chainTxStatsLabels.length; i++) { + chainTxStats.push(promiseResults[i + 2]); + } - res.locals.chainTxStats = chainTxStats; + res.locals.chainTxStats = chainTxStats; + } res.render("index"); });