Poll for system_health (keep-alive) (#634)

This commit is contained in:
Jaco Greeff 2019-01-21 17:04:55 +01:00 committed by GitHub
parent 2ca3c16966
commit d3202c79a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,17 +2,32 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiProps } from '@polkadot/ui-api/types';
import { BareProps } from '@polkadot/ui-app/types';
import React from 'react';
import { withApi } from '@polkadot/ui-api/with';
import { BestNumber, Chain, NodeName, NodeVersion } from '@polkadot/ui-reactive/index';
type Props = BareProps & {};
type Props = ApiProps & BareProps & {};
const HEALTH_POLL = 22500;
const pkgJson = require('../package.json');
export default class NodeInfo extends React.PureComponent<Props> {
class NodeInfo extends React.PureComponent<Props> {
componentDidMount () {
const { api } = this.props;
window.setInterval(() => {
api.rpc.system
.health()
.catch(() => {
// ignore
});
}, HEALTH_POLL);
}
render () {
return (
<div className='apps--NodeInfo'>
@ -29,3 +44,5 @@ export default class NodeInfo extends React.PureComponent<Props> {
);
}
}
export default withApi(NodeInfo);