2022-07-13 17:18:30 +00:00
|
|
|
package kv
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"context"
|
|
|
|
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/config/features"
|
2022-07-13 17:18:30 +00:00
|
|
|
bolt "go.etcd.io/bbolt"
|
|
|
|
)
|
|
|
|
|
|
|
|
var migrationBlindedBeaconBlocksKey = []byte("blinded-beacon-blocks-enabled")
|
|
|
|
|
|
|
|
func migrateBlindedBeaconBlocksEnabled(ctx context.Context, db *bolt.DB) error {
|
|
|
|
if !features.Get().EnableOnlyBlindedBeaconBlocks {
|
|
|
|
return nil // Only write to the migrations bucket if the feature is enabled.
|
|
|
|
}
|
|
|
|
if updateErr := db.Update(func(tx *bolt.Tx) error {
|
|
|
|
mb := tx.Bucket(migrationsBucket)
|
|
|
|
if b := mb.Get(migrationBlindedBeaconBlocksKey); bytes.Equal(b, migrationCompleted) {
|
|
|
|
return nil // Migration already completed.
|
|
|
|
}
|
|
|
|
return mb.Put(migrationBlindedBeaconBlocksKey, migrationCompleted)
|
|
|
|
}); updateErr != nil {
|
|
|
|
return updateErr
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|