pond: List node balances
This commit is contained in:
parent
4381448c04
commit
6f3285d2fb
@ -6,8 +6,14 @@
|
|||||||
|
|
||||||
.FullNode {
|
.FullNode {
|
||||||
background: #f9be77;
|
background: #f9be77;
|
||||||
margin-bottom: 5px;
|
|
||||||
padding: 5px;
|
|
||||||
user-select: text;
|
user-select: text;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
min-width: 40em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CristalScroll {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
@ -6,6 +6,10 @@ const stateConnected = 'connected'
|
|||||||
const stateConnecting = 'connecting'
|
const stateConnecting = 'connecting'
|
||||||
const stateGettingToken = 'getting-token'
|
const stateGettingToken = 'getting-token'
|
||||||
|
|
||||||
|
async function awaitListReducer(prev, c) {
|
||||||
|
return [...await prev, await c]
|
||||||
|
}
|
||||||
|
|
||||||
class FullNode extends React.Component {
|
class FullNode extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
@ -41,7 +45,8 @@ class FullNode extends React.Component {
|
|||||||
|
|
||||||
version: {Version: "~version~"},
|
version: {Version: "~version~"},
|
||||||
id: "~peerid~",
|
id: "~peerid~",
|
||||||
peers: -1
|
peers: -1,
|
||||||
|
balances: []
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const id = await this.state.client.call("Filecoin.ID", [])
|
const id = await this.state.client.call("Filecoin.ID", [])
|
||||||
@ -50,7 +55,7 @@ class FullNode extends React.Component {
|
|||||||
this.props.onConnect(client, id)
|
this.props.onConnect(client, id)
|
||||||
|
|
||||||
this.loadInfo()
|
this.loadInfo()
|
||||||
setInterval(this.loadInfo, 1000)
|
setInterval(this.loadInfo, 2050)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(token) // todo: use
|
console.log(token) // todo: use
|
||||||
@ -65,6 +70,15 @@ class FullNode extends React.Component {
|
|||||||
|
|
||||||
const tipset = await this.state.client.call("Filecoin.ChainHead", [])
|
const tipset = await this.state.client.call("Filecoin.ChainHead", [])
|
||||||
this.setState(() => ({tipset: tipset}))
|
this.setState(() => ({tipset: tipset}))
|
||||||
|
|
||||||
|
const addrss = await this.state.client.call('Filecoin.WalletList', [])
|
||||||
|
|
||||||
|
const balances = await addrss.map(async addr => {
|
||||||
|
const balance = await this.state.client.call('Filecoin.WalletBalance', [addr])
|
||||||
|
return [addr, balance]
|
||||||
|
}).reduce(awaitListReducer, Promise.resolve([]))
|
||||||
|
|
||||||
|
this.setState(() => ({balances: balances}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async startMining() {
|
async startMining() {
|
||||||
@ -89,12 +103,18 @@ class FullNode extends React.Component {
|
|||||||
mine = "Mining"
|
mine = "Mining"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let balances = this.state.balances.map(([addr, balance]) => (<div>{addr}: {balance} (ActTyp)</div>))
|
||||||
|
|
||||||
runtime = (
|
runtime = (
|
||||||
<div>
|
<div>
|
||||||
<div>v{this.state.version.Version}, {this.state.id.substr(-8)}, {this.state.peers} peers</div>
|
<div>v{this.state.version.Version}, {this.state.id.substr(-8)}, {this.state.peers} peers</div>
|
||||||
<div>Repo: LOTUS_PATH={this.props.node.Repo}</div>
|
<div>Repo: LOTUS_PATH={this.props.node.Repo}</div>
|
||||||
{chainInfo}
|
{chainInfo}
|
||||||
{mine}
|
{mine}
|
||||||
|
<div>
|
||||||
|
<div>Balances:</div>
|
||||||
|
<div>{balances}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -104,10 +124,11 @@ class FullNode extends React.Component {
|
|||||||
<Cristal
|
<Cristal
|
||||||
title={"Node " + this.props.node.ID}
|
title={"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}} >
|
||||||
|
<div className="CristalScroll">
|
||||||
<div className="FullNode">
|
<div className="FullNode">
|
||||||
<div>{this.props.node.ID} - {this.state.state}</div>
|
<div>{this.props.node.ID} - {this.state.state}</div>
|
||||||
{runtime}
|
{runtime}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Cristal>
|
</Cristal>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user