This repository has been archived by the owner on Feb 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from etclabscore/fix/miner-stats-pagination
fix: add miner stats pagination by block range
- Loading branch information
Showing
12 changed files
with
236 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import React from "react"; | ||
import { Grid, IconButton, Typography } from "@material-ui/core"; | ||
import { ArrowForwardIos, ArrowBackIos } from "@material-ui/icons"; | ||
|
||
interface IProps { | ||
from: number; | ||
to: number; | ||
disableNext?: boolean; | ||
disablePrev?: boolean; | ||
onNext?: () => void; | ||
onPrev?: () => void; | ||
style?: any; | ||
} | ||
|
||
const BlockPagination: React.FC<IProps> = (props) => { | ||
|
||
return ( | ||
<Grid container> | ||
<Grid container justify="flex-end"> | ||
<IconButton onClick={props.onPrev} disabled={props.disablePrev}> | ||
<ArrowBackIos /> | ||
</IconButton> | ||
<IconButton onClick={props.onNext} disabled={props.disableNext}> | ||
<ArrowForwardIos /> | ||
</IconButton> | ||
</Grid> | ||
<Grid container justify="flex-end"> | ||
<Typography>Showing {(props.to - props.from) + 1} Block Range: <b>{props.to}</b> - {props.from}</Typography> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default BlockPagination; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import BlockPagination from "./BlockPagination"; | ||
export default BlockPagination; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React from "react"; | ||
import BigNumber from "bignumber.js"; | ||
import { hashesToGH } from "../formatters"; | ||
import { hexToNumber } from "@etclabscore/eserialize"; | ||
import { Grid } from "@material-ui/core"; | ||
import ChartCard from "../ChartCard"; | ||
import { VictoryLine, VictoryBar, VictoryChart } from "victory"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
const config = { | ||
blockTime: 15, // seconds | ||
blockHistoryLength: 100, | ||
chartHeight: 200, | ||
chartWidth: 400, | ||
}; | ||
|
||
const blockMapGasUsed = (block: any) => { | ||
return { | ||
x: hexToNumber(block.number), | ||
y: new BigNumber(block.gasUsed).dividedBy(1000000), | ||
}; | ||
}; | ||
|
||
const blockMapUncles = (block: any) => { | ||
return { | ||
x: hexToNumber(block.number), | ||
y: block.uncles.length, | ||
}; | ||
}; | ||
|
||
const blockMapHashRate = (block: any) => { | ||
return { | ||
x: hexToNumber(block.number), | ||
y: hashesToGH(new BigNumber(block.difficulty, 16).dividedBy(config.blockTime)), | ||
}; | ||
}; | ||
|
||
const blockMapTransactionCount = (block: any) => { | ||
return { | ||
x: hexToNumber(block.number), | ||
y: block.transactions.length, | ||
}; | ||
}; | ||
|
||
interface IProps { | ||
blocks: any[]; | ||
victoryTheme?: any; | ||
} | ||
|
||
const StatCharts: React.FC<IProps> = ({ blocks, victoryTheme }) => { | ||
const { t } = useTranslation(); | ||
return ( | ||
<Grid item container> | ||
<Grid key="hashChart" item xs={12} md={6} lg={3}> | ||
<ChartCard title={t("Hash Rate")}> | ||
<VictoryChart height={config.chartHeight} width={config.chartWidth} theme={victoryTheme as any}> | ||
<VictoryLine data={blocks.map(blockMapHashRate)} /> | ||
</VictoryChart> | ||
</ChartCard> | ||
</Grid> | ||
<Grid key="txChart" item xs={12} md={6} lg={3}> | ||
<ChartCard title={t("Transaction count")}> | ||
<VictoryChart height={config.chartHeight} width={config.chartWidth} theme={victoryTheme as any}> | ||
<VictoryBar data={blocks.map(blockMapTransactionCount)} /> | ||
</VictoryChart> | ||
</ChartCard> | ||
</Grid> | ||
<Grid key="gasUsed" item xs={12} md={6} lg={3}> | ||
<ChartCard title={t("Gas Used")}> | ||
<VictoryChart height={config.chartHeight} width={config.chartWidth} theme={victoryTheme as any}> | ||
<VictoryBar data={blocks.map(blockMapGasUsed)} /> | ||
</VictoryChart> | ||
</ChartCard> | ||
</Grid> | ||
<Grid key="uncles" item xs={12} md={6} lg={3}> | ||
<ChartCard title={t("Uncles")}> | ||
<VictoryChart height={config.chartHeight} width={config.chartWidth} theme={victoryTheme as any}> | ||
<VictoryBar data={blocks.map(blockMapUncles)} /> | ||
</VictoryChart> | ||
</ChartCard> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default StatCharts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import StatCharts from "./StatCharts"; | ||
export default StatCharts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.