pond: Stopping storage nodes

This commit is contained in:
Łukasz Magiera 2019-09-17 14:53:43 +02:00
parent 9353cdb537
commit 215f95aa5b
3 changed files with 16 additions and 4 deletions

View File

@ -27,11 +27,15 @@ class Address extends React.Component {
componentDidMount() {
this.refresh()
if(!this.props.ts) {
let updates = setInterval(this.refresh, 2050)
this.props.client.on('close', () => clearInterval(updates))
this.updates = setInterval(this.refresh, 2050)
this.props.client.on('close', () => clearInterval(this.updates))
}
}
componentWillUnmount() {
clearInterval(this.updates)
}
async refresh() {
let balance = 0
let actor = {}

View File

@ -65,6 +65,7 @@ class NodeList extends React.Component {
pondClient={this.props.client}
fullConn={this.state.nodes[fullId].conn}
mountWindow={this.props.mountWindow}
stop={this.stopNode(node.ID, onClose)}
/>)
}
})

View File

@ -29,6 +29,7 @@ class StorageNode extends React.Component {
this.loadInfo = this.loadInfo.bind(this)
this.sealGarbage = this.sealGarbage.bind(this)
this.stop = this.stop.bind(this)
this.connect()
}
@ -59,7 +60,8 @@ class StorageNode extends React.Component {
// this.props.onConnect(client, id) // TODO: dedupe connecting part
this.loadInfo()
setInterval(this.loadInfo, 1050)
let updates = setInterval(this.loadInfo, 1050)
client.on('close', () => clearInterval(updates))
})
console.log(token) // todo: use
@ -89,6 +91,10 @@ class StorageNode extends React.Component {
await this.state.client.call("Filecoin.StoreGarbageData", [])
}
async stop() {
await this.props.stop()
}
render() {
let runtime = <div></div>
if (this.state.actor) {
@ -117,7 +123,8 @@ class StorageNode extends React.Component {
return <Cristal
title={"Storage Miner Node " + this.props.node.ID}
initialPosition={{x: this.props.node.ID*30, y: this.props.node.ID * 30}}>
initialPosition={{x: this.props.node.ID*30, y: this.props.node.ID * 30}}
onClose={this.stop} >
<div className="CristalScroll">
<div className="StorageNode">
{runtime}