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

Commit

Permalink
Warp sync status display
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Nov 1, 2016
1 parent cb3bb24 commit 7fe9df1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/src/api/format/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function outSyncing (syncing) {
break;

case 'blockGap':
syncing[key] = syncing[key].map(outNumber);
syncing[key] = syncing[key] ? syncing[key].map(outNumber) : syncing[key];
break;
}
});
Expand Down
3 changes: 3 additions & 0 deletions js/src/views/Application/Status/status.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@

.version {
}

.syncing {
}
47 changes: 42 additions & 5 deletions js/src/views/Application/Status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,63 @@ class Status extends Component {
clientVersion: PropTypes.string,
netPeers: PropTypes.object,
netChain: PropTypes.string,
syncing: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object
]),
isTest: PropTypes.bool
}

render () {
const { clientVersion, blockNumber, netChain, netPeers, isTest } = this.props;
const { clientVersion, blockNumber, netChain, netPeers, syncing, isTest } = this.props;
const netStyle = `${styles.network} ${styles[isTest ? 'networktest' : 'networklive']}`;
let blockStatus = null;

if (!blockNumber) {
return null;
}

if (syncing) {
if (!syncing.warpChunksAmount.eq(syncing.warpChunksProcessed)) {
blockStatus = (
<div className={ styles.syncing }>
{ syncing.warpChunksProcessed.mul(100).div(syncing.warpChunksAmount).toFormat(2) }% warp restore
</div>
);
} else {
let warpStatus = null;

if (syncing.blockGap) {
const [first, last] = syncing.blockGap;

warpStatus = (
<span>, { first.mul(100).div(last).toFormat(2) }% historic</span>
);
}

blockStatus = (
<div className={ styles.syncing }>
<span>{ syncing.currentBlock.toFormat() }/{ syncing.highestBlock.toFormat() } syncing</span>
{ warpStatus }
</div>
);
}
} else {
blockStatus = (
<div className={ styles.block }>
{ blockNumber.toFormat() } best block
</div>
);
}

return (
<div className={ styles.status }>
<div className={ styles.version }>
{ clientVersion }
</div>
<div className={ styles.netinfo }>
<div>
<div className={ styles.block }>
{ blockNumber.toFormat() } blocks
</div>
{ blockStatus }
<div className={ styles.peers }>
{ netPeers.active.toFormat() }/{ netPeers.connected.toFormat() }/{ netPeers.max.toFormat() } peers
</div>
Expand All @@ -61,13 +97,14 @@ class Status extends Component {
}

function mapStateToProps (state) {
const { blockNumber, clientVersion, netPeers, netChain, isTest } = state.nodeStatus;
const { blockNumber, clientVersion, netPeers, netChain, syncing, isTest } = state.nodeStatus;

return {
blockNumber,
clientVersion,
netPeers,
netChain,
syncing,
isTest
};
}
Expand Down

0 comments on commit 7fe9df1

Please sign in to comment.