Update chainwatch

This commit is contained in:
Łukasz Magiera 2020-03-09 06:43:32 +01:00
parent f17962182f
commit a46296d340
3 changed files with 64 additions and 12 deletions

View File

@ -17,8 +17,8 @@
{{$addr := .}}
<div>
<a href="key.html?w={{$addr}}">{{$addr}}</a>
<span><b>{{qstr "select count(distinct cid) from messages where \"from\"=?" $addr}}</b> outmsgs;</span>
<span><b>{{qstr "select count(distinct cid) from messages where \"to\"=?" $addr}}</b> inmsgs</span>
<span><b>{{qstr "select count(distinct cid) from messages where \"from\"=$1" $addr}}</b> outmsgs;</span>
<span><b>{{qstr "select count(distinct cid) from messages where \"to\"=$1" $addr}}</b> inmsgs</span>
</div>
{{end}}
</div>

View File

@ -2,7 +2,6 @@ package main
import (
"database/sql"
"fmt"
"sync"
"time"
@ -211,7 +210,7 @@ create table if not exists receipts
create index if not exists receipts_msg_state_index
on receipts (msg, state);
/*
create table if not exists miner_heads
(
head text not null,
@ -300,7 +299,7 @@ create index if not exists deal_activations_activation_epoch_index
create unique index if not exists deal_activations_deal_uindex
on deal_activations (deal);
*/
create table if not exists blocks_challenges
(
block text not null
@ -442,7 +441,7 @@ func (st *storage) storeActors(actors map[address.Address]map[types.Actor]actorI
}
func (st *storage) storeMiners(miners map[minerKey]*minerInfo) error {
tx, err := st.db.Begin()
/*tx, err := st.db.Begin()
if err != nil {
return err
}
@ -487,7 +486,8 @@ create temp table mh (like miner_heads excluding constraints) on commit drop;
return xerrors.Errorf("actor put: %w", err)
}
return tx.Commit()
return tx.Commit()*/
return nil
}
func (st *storage) storeHeaders(bhs map[cid.Cid]*types.BlockHeader, sync bool) error {
@ -839,7 +839,7 @@ func (st *storage) storeMpoolInclusions(msgs []api.MpoolUpdate) error {
}
func (st *storage) storeDeals(deals map[string]api.MarketDeal) error {
tx, err := st.db.Begin()
/*tx, err := st.db.Begin()
if err != nil {
return err
}
@ -932,7 +932,7 @@ func (st *storage) storeDeals(deals map[string]api.MarketDeal) error {
if err := tx.Commit(); err != nil {
return err
}
*/
return nil
}

View File

@ -9,6 +9,9 @@ import (
"strconv"
rice "github.com/GeertJohan/go.rice"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
@ -243,6 +246,45 @@ func (h *handler) qstrs(q string, n int, p ...interface{}) ([]string, error) {
return c, nil
}
type sbig types.BigInt
func (bi *sbig) Scan(value interface{}) error {
switch value := value.(type) {
case string:
i, ok := big.NewInt(0).SetString(value, 10)
if !ok {
if value == "<nil>" {
return nil
}
return xerrors.Errorf("failed to parse bigint string: '%s'", value)
}
bi.Int = i
return nil
case int64:
bi.Int = big.NewInt(value).Int
return nil
default:
return xerrors.Errorf("non-string types unsupported: %T", value)
}
}
type Message struct {
To address.Address
From address.Address
Nonce uint64
Value sbig
GasPrice sbig
GasLimit sbig
Method abi.MethodNum
Params []byte
}
func (h *handler) messages(filter string, args ...interface{}) (out []types.Message, err error) {
if len(filter) > 0 {
filter = " where " + filter
@ -255,7 +297,7 @@ func (h *handler) messages(filter string, args ...interface{}) (out []types.Mess
return nil, err
}
for rws.Next() {
var r types.Message
var r Message
var cs string
if err := rws.Scan(
@ -276,11 +318,21 @@ func (h *handler) messages(filter string, args ...interface{}) (out []types.Mess
if err != nil {
return nil, err
}
if c != r.Cid() {
tr := types.Message{
To: r.To,
From: r.From,
Nonce: r.Nonce,
Value: types.BigInt(r.Value),
GasPrice: types.BigInt(r.GasPrice),
GasLimit: types.BigInt(r.GasLimit),
Method: r.Method,
Params: r.Params,
}
if c != tr.Cid() {
log.Warn("msg cid doesn't match")
}
out = append(out, r)
out = append(out, tr)
}
return