pond: Gas-related updates

This commit is contained in:
Łukasz Magiera 2019-08-19 16:47:09 +02:00
parent aed7b8b640
commit d2f6105649
6 changed files with 48 additions and 21 deletions

View File

@ -4,9 +4,9 @@ import * as multihash from "multihashes";
import State from "./State";
import methods from "./chain/methods";
function truncAddr(addr) {
if (addr.length > 21) {
return <abbr title={addr}>{addr.substr(0, 18) + '..'}</abbr>
function truncAddr(addr, len) {
if (addr.length > len) {
return <abbr title={addr}>{addr.substr(0, len - 3) + '..'}</abbr>
}
return addr
}
@ -72,7 +72,7 @@ class Address extends React.Component {
if(this.props.add1k) {
add1k = <span>&nbsp;<a href="#" onClick={() => this.props.add1k(this.props.addr)}>[+1k]</a></span>
}
let addr = truncAddr(this.props.addr)
let addr = truncAddr(this.props.addr, this.props.short ? 12 : 17)
let actInfo = <span>(?)</span>
if(this.state.balance >= 0) {
@ -80,17 +80,21 @@ class Address extends React.Component {
addr = <a href="#" onClick={this.openState}>{addr}</a>
}
let balance = <span>:&nbsp;{this.state.balance}</span>
let balance = <span>:&nbsp;{this.state.balance}&nbsp;</span>
if(this.props.nobalance) {
balance = <span></span>
balance = <span/>
}
if(this.props.short) {
actInfo = <span/>
balance = <span/>
}
let transfer = <span></span>
let transfer = <span/>
if(this.props.transfer) {
transfer = <span>&nbsp;{this.props.transfer}FIL</span>
}
return <span>{addr}{balance}&nbsp;{actInfo}{add1k}{transfer}</span>
return <span>{addr}{balance}{actInfo}{add1k}{transfer}</span>
}
}

View File

@ -64,6 +64,7 @@
}
.ChainExplorer-at {
min-width: 40em;
background: #77ff77;
}

View File

@ -14,8 +14,16 @@ class Block extends React.Component {
async loadHeader() {
const header = await this.props.conn.call('Filecoin.ChainGetBlock', [this.props.cid])
const messages = await this.props.conn.call('Filecoin.ChainGetBlockMessages', [this.props.cid])
console.log(messages)
let messages = await this.props.conn.call('Filecoin.ChainGetBlockMessages', [this.props.cid])
let receipts = await this.props.conn.call('Filecoin.ChainGetBlockReceipts', [this.props.cid])
messages = [
...(messages.BlsMessages.map(m => ({...m, type: 'BLS'}))),
...(messages.SecpkMessages.map(m => ({...(m.Message), type: 'Secpk'})))
]
messages = messages.map((msg, k) => ({...msg, receipt: receipts[k]}))
this.setState({header: header, messages: messages})
}
@ -24,15 +32,12 @@ class Block extends React.Component {
if (this.state.header) {
let head = this.state.header
let messages = [
...(this.state.messages.BlsMessages.map(m => ({...m, type: 'BLS'}))),
...(this.state.messages.SecpkMessages.map(m => ({...(m.Message), type: 'Secpk'})))
].map(m => (
const messages = this.state.messages.map(m => (
<div>
<Address client={this.props.conn} addr={m.From} mountWindow={this.props.mountWindow}/><b>&nbsp;=>&nbsp;</b>
<Address client={this.props.conn} addr={m.To} mountWindow={this.props.mountWindow} transfer={m.Value} method={m.Method}/>
<span>&nbsp;{m.receipt.GasUsed}Gas</span>
{m.receipt.ExitCode !== 0 ? <span>&nbsp;<b>EXIT:{m.receipt.ExitCode}</b></span> : <span/>}
</div>
))

View File

@ -1,10 +1,19 @@
import React from 'react';
import Block from "./Block";
import Address from "./Address";
export class BlockLinks extends React.Component {
render() {
return this.props.cids.map(c => <BlockLink key={c} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/>)
return this.props.cids.map((c, k) => {
let block
if(this.props.blocks) {
block = this.props.blocks[k]
}
return <BlockLink key={c} block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/>
})
}
}
@ -20,7 +29,12 @@ class BlockLink extends React.Component {
}
render() {
return <a href="#" onClick={this.openBlockViewer}><abbr title={this.props.cid['/']}>{this.props.cid['/'].substr(-8)}</abbr></a>
let info = <span></span>
if(this.props.block) {
info = <span>&nbsp;(by <Address client={this.props.conn} addr={this.props.block.Miner} mountWindow={this.props.mountWindow} short={true}/>)</span>
}
return <span><a href="#" onClick={this.openBlockViewer}><abbr title={this.props.cid['/']}>{this.props.cid['/'].substr(-8)}</abbr></a>{info}</span>
}
}

View File

@ -114,12 +114,15 @@ class ChainExplorer extends React.Component {
const ts = this.state.cache[row]
let msgc = -1
if(ts.Cids[0] && this.state.messages[ts.Cids[0]['/']]) {
if(ts.Cids[0] && this.state.messages[ts.Cids[0]['/']]) { // TODO: get from all blks
msgc = this.state.messages[ts.Cids[0]['/']].SecpkMessages.length + this.state.messages[ts.Cids[0]['/']].BlsMessages.length
}
if(msgc > 0) {
msgc = <b>{msgc}</b>
}
info = <span>
<BlockLinks cids={ts.Cids} conn={this.props.client} mountWindow={this.props.mountWindow} /> Msgs: <b>{msgc}</b>
<BlockLinks cids={ts.Cids} blocks={ts.Blocks} conn={this.props.client} mountWindow={this.props.mountWindow} /> Msgs: {msgc}
</span>
}

View File

@ -4,7 +4,7 @@ import { Tagged } from 'borc'
async function pushMessage(client, from, inmsg) {
if(!inmsg.GasLimit) {
inmsg.GasLimit = "0"
inmsg.GasLimit = "1000"
}
if(!inmsg.GasPrice) {
inmsg.GasPrice = "0"