diff --git a/cmd/lotus-chainwatch/site/keys.html b/cmd/lotus-chainwatch/site/keys.html
index 01ba3d241..1ad72fafe 100644
--- a/cmd/lotus-chainwatch/site/keys.html
+++ b/cmd/lotus-chainwatch/site/keys.html
@@ -17,8 +17,8 @@
{{$addr := .}}
{{$addr}}
-
{{qstr "select count(distinct cid) from messages where \"from\"=?" $addr}} outmsgs;
-
{{qstr "select count(distinct cid) from messages where \"to\"=?" $addr}} inmsgs
+
{{qstr "select count(distinct cid) from messages where \"from\"=$1" $addr}} outmsgs;
+
{{qstr "select count(distinct cid) from messages where \"to\"=$1" $addr}} inmsgs
{{end}}
diff --git a/cmd/lotus-chainwatch/storage.go b/cmd/lotus-chainwatch/storage.go
index c90a653b9..024d3ba85 100644
--- a/cmd/lotus-chainwatch/storage.go
+++ b/cmd/lotus-chainwatch/storage.go
@@ -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,
@@ -303,7 +302,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
@@ -445,7 +444,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
}
@@ -490,7 +489,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 {
@@ -842,7 +842,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
}
@@ -935,7 +935,7 @@ func (st *storage) storeDeals(deals map[string]api.MarketDeal) error {
if err := tx.Commit(); err != nil {
return err
}
-
+*/
return nil
}
diff --git a/cmd/lotus-chainwatch/templates.go b/cmd/lotus-chainwatch/templates.go
index 32b9d398c..d1ad6984d 100644
--- a/cmd/lotus-chainwatch/templates.go
+++ b/cmd/lotus-chainwatch/templates.go
@@ -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 == "" {
+ 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