From 3b0d8fdd296f546281c40669cc6467a85539f105 Mon Sep 17 00:00:00 2001 From: zenground0 Date: Wed, 15 Mar 2023 11:19:10 -0600 Subject: [PATCH] P0 fix --- cmd/lotus-shed/evmbalance.go | 37 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/cmd/lotus-shed/evmbalance.go b/cmd/lotus-shed/evmbalance.go index baa6a5162..c04f70896 100644 --- a/cmd/lotus-shed/evmbalance.go +++ b/cmd/lotus-shed/evmbalance.go @@ -3,10 +3,12 @@ package main import ( "context" "fmt" - "io" + "os" + "path/filepath" "github.com/filecoin-project/go-state-types/big" + badgerbs "github.com/filecoin-project/lotus/blockstore/badger" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/go-state-types/abi" @@ -17,9 +19,7 @@ import ( "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/state" - "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/repo" ) @@ -62,26 +62,25 @@ var evmBalanceCmd = &cli.Command{ defer lkrepo.Close() //nolint:errcheck - bs, err := lkrepo.Blockstore(ctx, repo.HotBlockstore) - if err != nil { - return fmt.Errorf("failed to open blockstore: %w", err) - } - - defer func() { - if c, ok := bs.(io.Closer); ok { - if err := c.Close(); err != nil { - log.Warnf("failed to close blockstore: %s", err) - } - } - }() - - mds, err := lkrepo.Datastore(context.Background(), "/metadata") + path, err := lkrepo.SplitstorePath() if err != nil { return err } - cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil) - defer cs.Close() //nolint:errcheck + path = filepath.Join(path, "hot.badger") + if err := os.MkdirAll(path, 0755); err != nil { + return err + } + + opts, err := repo.BadgerBlockstoreOptions(repo.HotBlockstore, path, lkrepo.Readonly()) + if err != nil { + return err + } + + bs, err := badgerbs.Open(opts) + if err != nil { + return err + } cst := cbor.NewCborStore(bs) st, err := state.LoadStateTree(cst, sroot)