diff --git a/cmd/lotus-shed/migrations.go b/cmd/lotus-shed/migrations.go index e2a66f0676..bde72468e4 100644 --- a/cmd/lotus-shed/migrations.go +++ b/cmd/lotus-shed/migrations.go @@ -3,7 +3,8 @@ package main import ( "context" "fmt" - "io" + "os" + "path/filepath" "strconv" "time" @@ -32,6 +33,7 @@ import ( "github.com/filecoin-project/specs-actors/v7/actors/migration/nv15" "github.com/filecoin-project/lotus/blockstore" + badgerbs "github.com/filecoin-project/lotus/blockstore/badger" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" @@ -102,16 +104,34 @@ var migrationsCmd = &cli.Command{ defer lkrepo.Close() //nolint:errcheck - bs, err := lkrepo.Blockstore(ctx, repo.UniversalBlockstore) + path, err := lkrepo.SplitstorePath() if err != nil { - return fmt.Errorf("failed to open blockstore: %w", err) + return err + } + + 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 + } + + // bs, err := lkrepo.Blockstore(ctx, repo.UniversalBlockstore) + // 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) - } + if err := bs.Close(); err != nil { + log.Warnf("failed to close blockstore: %s", err) } }()