Skip to content

Commit

Permalink
make old freezer not readonly so that .meta files are created
Browse files Browse the repository at this point in the history
  • Loading branch information
alecps committed May 8, 2024
1 parent 8f36c0d commit 578c06a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion op-chain-ops/cmd/celo-dbmigrate/ancients.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type RLPBlockRange struct {
}

func migrateAncientsDb(oldDBPath, newDBPath string, batchSize uint64) (uint64, error) {
oldFreezer, err := rawdb.NewChainFreezer(filepath.Join(oldDBPath, "ancient"), "", true)
oldFreezer, err := rawdb.NewChainFreezer(filepath.Join(oldDBPath, "ancient"), "", false) // TODO can't be readonly because we need the .meta files to be created
if err != nil {
return 0, fmt.Errorf("failed to open old freezer: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions op-chain-ops/cmd/celo-dbmigrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// How to run:
// go run main.go -oldDB /path/to/oldDB -newDB /path/to/newDB [-batchSize 1000] [-verbosity 3] [-clear-all] [-clear-nonAncients]
// go run ./op-chain-ops/cmd/celo-dbmigrate -oldDB /path/to/oldDB -newDB /path/to/newDB [-batchSize 1000] [-verbosity 3] [-clear-all] [-clear-nonAncients]
//
// This script will migrate block data from the old database to the new database
// You can set the log level using the -verbosity flag
Expand Down Expand Up @@ -68,12 +68,12 @@ func main() {
log.Crit("Failed to migrate ancients database", "err", err)
}

var numAncientsNonAncients uint64
if numAncientsNonAncients, err = migrateNonAncientsDb(*oldDBPath, *newDBPath, numAncientsNew-1, *batchSize); err != nil {
var numNonAncients uint64
if numNonAncients, err = migrateNonAncientsDb(*oldDBPath, *newDBPath, numAncientsNew-1, *batchSize); err != nil {
log.Crit("Failed to migrate non-ancients database", "err", err)
}

log.Info("Migration Completed", "migratedAncients", numAncientsNew, "migratedNonAncients", numAncientsNonAncients)
log.Info("Migration Completed", "migratedAncients", numAncientsNew, "migratedNonAncients", numNonAncients)
}

func migrateNonAncientsDb(oldDbPath, newDbPath string, lastAncientBlock, batchSize uint64) (uint64, error) {
Expand Down

0 comments on commit 578c06a

Please sign in to comment.