From 08917b829e4e686b4d0a88a427b18bb17e8e4fa3 Mon Sep 17 00:00:00 2001 From: baxy Date: Mon, 18 Feb 2019 22:55:13 +0200 Subject: [PATCH] Added config AVG_GAS_PRICE_ENABLED --- .../NetStats/BigChartsSectionItem/index.js | 3 ++- app/components/NetStats/NodeItem/index.js | 2 +- app/routes/pages/NetworkStatistics/index.js | 17 +++++++++++------ app/utils/helpers.js | 2 +- config.js.example | 3 ++- set-env-vars.js | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/components/NetStats/BigChartsSectionItem/index.js b/app/components/NetStats/BigChartsSectionItem/index.js index efbabf6..4a25241 100644 --- a/app/components/NetStats/BigChartsSectionItem/index.js +++ b/app/components/NetStats/BigChartsSectionItem/index.js @@ -11,6 +11,7 @@ import PropTypes from 'prop-types'; import RightContainer from './RightContainer'; import TopLeft from './TopLeft/index'; import TopRight from './TopRight/index'; +import { AVG_GAS_PRICE_ENABLED } from 'config'; class BigChartsSectionItem extends React.Component { render() { @@ -26,7 +27,7 @@ class BigChartsSectionItem extends React.Component { - + {(topRightReducer !== 'pendingLastBlock' || (topRightReducer === 'pendingLastBlock' && AVG_GAS_PRICE_ENABLED)) && } diff --git a/app/components/NetStats/NodeItem/index.js b/app/components/NetStats/NodeItem/index.js index d7e0108..5db0f76 100644 --- a/app/components/NetStats/NodeItem/index.js +++ b/app/components/NetStats/NodeItem/index.js @@ -231,7 +231,7 @@ class NodeItem extends React.Component { {lastBlockUnclesCount} diff --git a/app/routes/pages/NetworkStatistics/index.js b/app/routes/pages/NetworkStatistics/index.js index 3cbe85e..f0b950b 100644 --- a/app/routes/pages/NetworkStatistics/index.js +++ b/app/routes/pages/NetworkStatistics/index.js @@ -19,6 +19,7 @@ import { loadBlockPropagation as loadBlockPropagationAction } from 'actions/bloc import { loadMinersTop as loadMinersTopAction } from 'actions/minersTop'; import { loadPendingLastBlock as loadPendingLastBlockAction } from 'actions/pendingLastBlock'; import { startTickTimer, stopTickTimer } from 'actions/global'; +import { AVG_GAS_PRICE_ENABLED } from 'config'; class NetworkStatistics extends React.Component { componentDidMount() { @@ -40,9 +41,11 @@ class NetworkStatistics extends React.Component { }); }); }); - DsService.getRawRecord('pending/v2/lastBlockData').then( ( record ) => { - record.subscribe(this.handlePendingLastBlockSubscribe.bind(this), true); - }); + if (AVG_GAS_PRICE_ENABLED) { + DsService.getRawRecord('pending/v2/lastBlockData').then((record) => { + record.subscribe(this.handlePendingLastBlockSubscribe.bind(this), true); + }); + } } componentWillUnmount() { this.props.dispatch(stopTickTimer()); @@ -63,9 +66,11 @@ class NetworkStatistics extends React.Component { } }); }); - DsService.getRawRecord('pending/lastBlockData').then( ( record ) => { - record.unsubscribe(); - }); + if (AVG_GAS_PRICE_ENABLED) { + DsService.getRawRecord('pending/v2/lastBlockData').then((record) => { + record.unsubscribe(); + }); + } } handlePendingLastBlockSubscribe(data) { this.props.dispatch(loadPendingLastBlockAction(data)); diff --git a/app/utils/helpers.js b/app/utils/helpers.js index a235f69..60aaf79 100644 --- a/app/utils/helpers.js +++ b/app/utils/helpers.js @@ -130,7 +130,7 @@ export function convertHashes(hashes, decimals = 2) { let unit = ''; if(hashes !== 0 && hashes < 1000) { - result = hashes; + result = parseInt(hashes, 10); unit = ''; } diff --git a/config.js.example b/config.js.example index f363a22..af803a3 100644 --- a/config.js.example +++ b/config.js.example @@ -5,5 +5,6 @@ const config = { DS_PASS: '', DS_NAMESPACE: 'ethstats/', EXPLORER_URL: '', - PRIVACY_POLICY: false + PRIVACY_POLICY: false, + AVG_GAS_PRICE_ENABLED: true }; diff --git a/set-env-vars.js b/set-env-vars.js index f57df4b..da1496d 100755 --- a/set-env-vars.js +++ b/set-env-vars.js @@ -25,7 +25,7 @@ config = JSON.parse(config); Object.keys(config).forEach(item => { if (process.env[item]) { - if (item === 'PRIVACY_POLICY') { + if (item === 'PRIVACY_POLICY' || item === 'AVG_GAS_PRICE_ENABLED') { config[item] = process.env[item] === 'true'; } else { config[item] = process.env[item];