Skip to content

Commit

Permalink
Added config AVG_GAS_PRICE_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
baxy committed Feb 18, 2019
1 parent 6c95694 commit 08917b8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/components/NetStats/BigChartsSectionItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -26,7 +27,7 @@ class BigChartsSectionItem extends React.Component {
<Icon name={iconName} />
</ChartIcon>
<FlexRow>
<TopRight color={color} mainTitle={thirdTitle} reducerName={topRightReducer}/>
{(topRightReducer !== 'pendingLastBlock' || (topRightReducer === 'pendingLastBlock' && AVG_GAS_PRICE_ENABLED)) && <TopRight color={color} mainTitle={thirdTitle} reducerName={topRightReducer}/>}
</FlexRow>
<BigChart valuePrefix={valuePrefix} labelPrefix={labelPrefix} color={color} dataKey={dataKey} measureUnit={measureUnit} tooltipKey={tooltipKey} hasDomain={hasDomain} chartReducer={chartReducer} hasNavigation/>
</RightContainer>
Expand Down
2 changes: 1 addition & 1 deletion app/components/NetStats/NodeItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class NodeItem extends React.Component {
<Detail width="55px" color={colors.nameColor} data-tip data-for={`viewDetails-${shortNodeName}`}>{lastBlockUnclesCount}</Detail>
<Counter
nodeIsActive={data['ethstats:nodeData']['ethstats:nodeIsActive']}
receivedTimestamp={data['ethstats:nodeBlockData'] && data['ethstats:nodeBlockData']['ethstats:receivedTimestamp']}
receivedTimestamp={data['ethstats:nodeBlockData'] && data['ethstats:nodeBlockData']['ethstats:receivedTimestamp'].toString()}
blockNumber={data['ethstats:nodeBlockData'] && parseInt(data['ethstats:nodeBlockData']['ethon:number'], 10)}
syncBlockNumber={data['ethstats:nodeSyncInfo'] && parseInt(data['ethstats:nodeSyncInfo']['ethstats:currentBlock'], 10)}
/>
Expand Down
17 changes: 11 additions & 6 deletions app/routes/pages/NetworkStatistics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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());
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion app/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function convertHashes(hashes, decimals = 2) {
let unit = '';

if(hashes !== 0 && hashes < 1000) {
result = hashes;
result = parseInt(hashes, 10);
unit = '';
}

Expand Down
3 changes: 2 additions & 1 deletion config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ const config = {
DS_PASS: '',
DS_NAMESPACE: 'ethstats/',
EXPLORER_URL: '',
PRIVACY_POLICY: false
PRIVACY_POLICY: false,
AVG_GAS_PRICE_ENABLED: true
};
2 changes: 1 addition & 1 deletion set-env-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 08917b8

Please sign in to comment.