mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"path"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
|
"github.com/prysmaticlabs/prysm/v3/io/file"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/db/kv"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// MigrateUp for a validator database.
|
|
func MigrateUp(cliCtx *cli.Context) error {
|
|
dataDir := cliCtx.String(cmd.DataDirFlag.Name)
|
|
|
|
if !file.FileExists(path.Join(dataDir, kv.ProtectionDbFileName)) {
|
|
return errors.New("No validator db found at path, nothing to migrate")
|
|
}
|
|
|
|
ctx := context.Background()
|
|
log.Info("Opening DB")
|
|
validatorDB, err := kv.NewKVStore(ctx, dataDir, &kv.Config{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Info("Running migrations")
|
|
return validatorDB.RunUpMigrations(ctx)
|
|
}
|
|
|
|
// MigrateDown for a validator database.
|
|
func MigrateDown(cliCtx *cli.Context) error {
|
|
dataDir := cliCtx.String(cmd.DataDirFlag.Name)
|
|
|
|
if !file.FileExists(path.Join(dataDir, kv.ProtectionDbFileName)) {
|
|
return errors.New("No validator db found at path, nothing to rollback")
|
|
}
|
|
|
|
ctx := context.Background()
|
|
log.Info("Opening DB")
|
|
validatorDB, err := kv.NewKVStore(ctx, dataDir, &kv.Config{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Info("Running migrations")
|
|
return validatorDB.RunDownMigrations(ctx)
|
|
}
|