Skip to content

Commit

Permalink
Open hotstore for migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Mar 30, 2023
1 parent 7a4082c commit ad0a54b
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions cmd/lotus-shed/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package main
import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"strconv"
"time"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}()

Expand Down

0 comments on commit ad0a54b

Please sign in to comment.