erigon-pulse/migrations/remove_clique.go

37 lines
715 B
Go
Raw Normal View History

package migrations
import (
"context"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
)
var removeCliqueBucket = Migration{
Name: "remove_clique_bucket",
Up: func(db kv.RwDB, tmpdir string, progress []byte, BeforeCommit Callback) (err error) {
tx, err := db.BeginRw(context.Background())
if err != nil {
return err
}
defer tx.Rollback()
2021-07-28 03:43:51 +00:00
if exists, err := tx.ExistsBucket(kv.Clique); err != nil {
return err
} else if !exists {
if err := BeforeCommit(tx, nil, true); err != nil {
return err
}
return tx.Commit()
}
2021-07-28 03:43:51 +00:00
if err := tx.DropBucket(kv.Clique); err != nil {
return err
}
if err := BeforeCommit(tx, nil, true); err != nil {
return err
}
return tx.Commit()
},
}