mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-16 06:58:20 +00:00
c4ab67832f
* migrate using tx commit * add improvement * fixed up test * rem fmt * gaz Co-authored-by: nisdas <nishdas93@gmail.com>
30 lines
472 B
Go
30 lines
472 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
|
|
bolt "go.etcd.io/bbolt"
|
|
)
|
|
|
|
var migrationCompleted = []byte("done")
|
|
|
|
type migration func(*bolt.Tx) error
|
|
|
|
var migrations = []migration{
|
|
migrateSnappyAttestationHistory,
|
|
}
|
|
|
|
// RunMigrations defined in the migrations array.
|
|
func (s *Store) RunMigrations(ctx context.Context) error {
|
|
for _, m := range migrations {
|
|
if ctx.Err() != nil {
|
|
return ctx.Err()
|
|
}
|
|
|
|
if err := s.db.Update(m); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|