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 State from "./State";
import methods from "./chain/methods"; import methods from "./chain/methods";
function truncAddr(addr) { function truncAddr(addr, len) {
if (addr.length > 21) { if (addr.length > len) {
return <abbr title={addr}>{addr.substr(0, 18) + '..'}</abbr> return <abbr title={addr}>{addr.substr(0, len - 3) + '..'}</abbr>
} }
return addr return addr
} }
@ -72,7 +72,7 @@ class Address extends React.Component {
if(this.props.add1k) { if(this.props.add1k) {
add1k = <span>&nbsp;<a href="#" onClick={() => this.props.add1k(this.props.addr)}>[+1k]</a></span> 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> let actInfo = <span>(?)</span>
if(this.state.balance >= 0) { if(this.state.balance >= 0) {
@ -80,17 +80,21 @@ class Address extends React.Component {
addr = <a href="#" onClick={this.openState}>{addr}</a> 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) { 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) { if(this.props.transfer) {
transfer = <span>&nbsp;{this.props.transfer}FIL</span> 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 { .ChainExplorer-at {
min-width: 40em;
background: #77ff77; background: #77ff77;
} }

View File

@ -14,8 +14,16 @@ class Block extends React.Component {
async loadHeader() { async loadHeader() {
const header = await this.props.conn.call('Filecoin.ChainGetBlock', [this.props.cid]) const header = await this.props.conn.call('Filecoin.ChainGetBlock', [this.props.cid])
const messages = await this.props.conn.call('Filecoin.ChainGetBlockMessages', [this.props.cid]) let messages = await this.props.conn.call('Filecoin.ChainGetBlockMessages', [this.props.cid])
console.log(messages) 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}) this.setState({header: header, messages: messages})
} }
@ -24,15 +32,12 @@ class Block extends React.Component {
if (this.state.header) { if (this.state.header) {
let head = this.state.header let head = this.state.header
const messages = this.state.messages.map(m => (
let messages = [
...(this.state.messages.BlsMessages.map(m => ({...m, type: 'BLS'}))),
...(this.state.messages.SecpkMessages.map(m => ({...(m.Message), type: 'Secpk'})))
].map(m => (
<div> <div>
<Address client={this.props.conn} addr={m.From} mountWindow={this.props.mountWindow}/><b>&nbsp;=>&nbsp;</b> <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}/> <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> </div>
)) ))

View File

@ -1,10 +1,19 @@
import React from 'react'; import React from 'react';
import Block from "./Block"; import Block from "./Block";
import Address from "./Address";
export class BlockLinks extends React.Component { export class BlockLinks extends React.Component {
render() { 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() { 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] const ts = this.state.cache[row]
let msgc = -1 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 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> 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> </span>
} }

View File

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