Merge pull request #3113 from filecoin-project/fix/chainwatch/calibration-improvements
Chainwatch Improvements
This commit is contained in:
commit
2e78ed685f
2
Makefile
2
Makefile
@ -148,7 +148,7 @@ BINS+=lotus-fountain
|
|||||||
|
|
||||||
lotus-chainwatch:
|
lotus-chainwatch:
|
||||||
rm -f lotus-chainwatch
|
rm -f lotus-chainwatch
|
||||||
go build -o lotus-chainwatch ./cmd/lotus-chainwatch
|
go build $(GOFLAGS) -o lotus-chainwatch ./cmd/lotus-chainwatch
|
||||||
.PHONY: lotus-chainwatch
|
.PHONY: lotus-chainwatch
|
||||||
BINS+=lotus-chainwatch
|
BINS+=lotus-chainwatch
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func main() {
|
|||||||
if err := logging.SetLogLevel("*", "info"); err != nil {
|
if err := logging.SetLogLevel("*", "info"); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
log.Info("Starting chainwatch")
|
log.Info("Starting chainwatch", " v", build.UserVersion())
|
||||||
|
|
||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "lotus-chainwatch",
|
Name: "lotus-chainwatch",
|
||||||
|
@ -8,8 +8,6 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/events/state"
|
"github.com/filecoin-project/lotus/chain/events/state"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -17,6 +15,8 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
_init "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
_init "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/multiformats/go-multihash"
|
||||||
typegen "github.com/whyrusleeping/cbor-gen"
|
typegen "github.com/whyrusleeping/cbor-gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -243,9 +243,13 @@ func (p *Processor) storeActorHeads(actors map[cid.Cid]ActorTips) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for code, actTips := range actors {
|
for code, actTips := range actors {
|
||||||
|
actorName := code.String()
|
||||||
|
if s, err := multihash.Decode(code.Hash()); err != nil {
|
||||||
|
actorName = string(s.Digest)
|
||||||
|
}
|
||||||
for _, actorInfo := range actTips {
|
for _, actorInfo := range actTips {
|
||||||
for _, a := range actorInfo {
|
for _, a := range actorInfo {
|
||||||
if _, err := stmt.Exec(a.addr.String(), code.String(), a.act.Head.String(), a.act.Nonce, a.act.Balance.String(), a.stateroot.String()); err != nil {
|
if _, err := stmt.Exec(a.addr.String(), actorName, a.act.Head.String(), a.act.Nonce, a.act.Balance.String(), a.stateroot.String()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,9 +289,13 @@ func (p *Processor) storeActorStates(actors map[cid.Cid]ActorTips) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for code, actTips := range actors {
|
for code, actTips := range actors {
|
||||||
|
actorName := code.String()
|
||||||
|
if s, err := multihash.Decode(code.Hash()); err != nil {
|
||||||
|
actorName = string(s.Digest)
|
||||||
|
}
|
||||||
for _, actorInfo := range actTips {
|
for _, actorInfo := range actTips {
|
||||||
for _, a := range actorInfo {
|
for _, a := range actorInfo {
|
||||||
if _, err := stmt.Exec(a.act.Head.String(), code.String(), a.state); err != nil {
|
if _, err := stmt.Exec(a.act.Head.String(), actorName, a.state); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,11 @@ create table if not exists chain_economics
|
|||||||
(
|
(
|
||||||
parent_state_root text not null
|
parent_state_root text not null
|
||||||
constraint chain_economics_pk primary key,
|
constraint chain_economics_pk primary key,
|
||||||
circulating_fil text not null
|
circulating_fil text not null,
|
||||||
|
vested_fil text not null,
|
||||||
|
mined_fil text not null,
|
||||||
|
burnt_fil text not null,
|
||||||
|
locked_fil text not null
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists block_cids
|
create table if not exists block_cids
|
||||||
@ -283,12 +287,16 @@ func (s *Syncer) storeCirculatingSupply(ctx context.Context, tipset *types.TipSe
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ceInsert := `insert into chain_economics (parent_state_root, circulating_fil) values ('%s', '%s');`
|
ceInsert := `insert into chain_economics (parent_state_root, circulating_fil, vested_fil, mined_fil, burnt_fil, locked_fil)` +
|
||||||
|
`values ('%s', '%s', '%s', '%s', '%s', '%s');`
|
||||||
|
|
||||||
if _, err := s.db.Exec(fmt.Sprintf(ceInsert,
|
if _, err := s.db.Exec(fmt.Sprintf(ceInsert,
|
||||||
tipset.ParentState().String(),
|
tipset.ParentState().String(),
|
||||||
// TODO: Include all the details maybe?
|
|
||||||
supply.FilCirculating.String(),
|
supply.FilCirculating.String(),
|
||||||
|
supply.FilVested.String(),
|
||||||
|
supply.FilMined.String(),
|
||||||
|
supply.FilBurnt.String(),
|
||||||
|
supply.FilLocked.String(),
|
||||||
)); err != nil {
|
)); err != nil {
|
||||||
return xerrors.Errorf("insert circulating supply for tipset (%s): %w", tipset.Key().String(), err)
|
return xerrors.Errorf("insert circulating supply for tipset (%s): %w", tipset.Key().String(), err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user