Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
feat: show inactive validators, yarn lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnygleason committed Jul 31, 2019
1 parent e686b0e commit 09c8d9f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ async function fetchValidatorIdentities(keys) {
*/
function getNetworkInflationRate(slot) {
const SLOTS_PER_SECOND = 1.0;
const SECONDS_PER_YEAR = (365.25 * 24.0 * 60.0 * 60.0);
const SECONDS_PER_YEAR = 365.25 * 24.0 * 60.0 * 60.0;
const SLOTS_PER_YEAR = SLOTS_PER_SECOND * SECONDS_PER_YEAR;
const DEFAULT_INITIAL = 0.15;
const DEFAULT_TERMINAL = 0.015;
Expand Down
7 changes: 6 additions & 1 deletion src/v2/components/TourDeSol/Cards/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import useStyles from './styles';

const Cards = () => {
const classes = useStyles();
const {cluster, validators, inactiveValidators, totalStakedTokens} = NodesStore;
const {
cluster,
validators,
inactiveValidators,
totalStakedTokens,
} = NodesStore;

const cards = [
{
Expand Down
20 changes: 11 additions & 9 deletions src/v2/components/Validators/Table/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const ValidatorsTable = ({separate}: {separate: boolean}) => {
const classes = useStyles();
const theme = useTheme();
const showTable = useMediaQuery(theme.breakpoints.up('md'));
const {validators} = NodesStore;
const {validators, inactiveValidators} = NodesStore;
const renderRow = row => {
const uptime = getUptime(row);
const uptime = row.uptime && getUptime(row);
const {identity = {}, nodePubkey, stake, commission} = row;
return (
<TableRow hover key={nodePubkey}>
Expand All @@ -42,14 +42,14 @@ const ValidatorsTable = ({separate}: {separate: boolean}) => {
<div>{identity.name || nodePubkey}</div>
</Link>
</TableCell>
<TableCell>{stake} Lamports</TableCell>
<TableCell>{commission}</TableCell>
<TableCell>{uptime}%</TableCell>
<TableCell>{(stake && (stake + ' Lamports')) || 'N/A'}</TableCell>
<TableCell>{commission || 'N/A'}</TableCell>
<TableCell>{(uptime && (uptime + '%')) || 'Node Unavailable'}</TableCell>
</TableRow>
);
};
const renderCard = card => {
const uptime = getUptime(card);
const uptime = card.uptime && getUptime(card);
const {identity = {}, nodePubkey, stake, commission} = card;
return (
<div
Expand All @@ -67,15 +67,15 @@ const ValidatorsTable = ({separate}: {separate: boolean}) => {
<Grid container spacing={1}>
<Grid item xs={4} zeroMinWidth>
<div className={classes.cardTitle}>Stake</div>
<div>{stake} Lamports</div>
<div>{(stake && (stake + ' Lamports')) || 'N/A'}</div>
</Grid>
<Grid item xs={4} zeroMinWidth>
<div className={classes.cardTitle}>Commission</div>
<div>{commission}</div>
<div>{commission || 'N/A'}</div>
</Grid>
<Grid item xs={4} zeroMinWidth>
<div className={classes.cardTitle}>Uptime</div>
<div>{uptime}%</div>
<div>{(uptime && (uptime + '%')) || 'Node Unavailable'}</div>
</Grid>
</Grid>
</div>
Expand Down Expand Up @@ -108,11 +108,13 @@ const ValidatorsTable = ({separate}: {separate: boolean}) => {
}}
>
{map(renderRow)(validators)}
{map(renderRow)(inactiveValidators)}
</TableBody>
</Table>
) : (
<div className={cn(classes.list, separate && classes.vertical)}>
{map(renderCard)(validators)}
{map(renderCard)(inactiveValidators)}
</div>
)}
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/v2/stores/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
get,
compose,
keys,
filter,
map,
mapValues,
pick,
Expand Down Expand Up @@ -72,6 +73,14 @@ class Store {
})(this.cluster.votingNow);
}

get inactiveValidators() {
let inactive = filter(
vote => !find({pubkey: vote.nodePubkey})(this.cluster.cluster),
)(this.cluster.votingAll);

return inactive;
}

get totalStakedTokens() {
return compose(
sumBy('stake'),
Expand All @@ -85,6 +94,7 @@ decorate(Store, {
updateClusterInfo: action.bound,
mapMarkers: computed,
validators: computed,
inactiveValidators: computed,
fetchClusterInfo: action.bound,
});

Expand Down

0 comments on commit 09c8d9f

Please sign in to comment.