erigon-pulse/migrations/remove_clique.go
2021-07-24 11:28:05 +07:00

38 lines
787 B
Go

package migrations
import (
"context"
"github.com/ledgerwatch/erigon/common/dbutils"
"github.com/ledgerwatch/erigon/ethdb"
)
var removeCliqueBucket = Migration{
Name: "remove_clique_bucket",
Up: func(db ethdb.RwKV, tmpdir string, progress []byte, BeforeCommit Callback) (err error) {
tx, err := db.BeginRw(context.Background())
if err != nil {
return err
}
defer tx.Rollback()
if exists, err := tx.ExistsBucket(dbutils.CliqueBucket); err != nil {
return err
} else if !exists {
if err := BeforeCommit(tx, nil, true); err != nil {
return err
}
return tx.Commit()
}
if err := tx.DropBucket(dbutils.CliqueBucket); err != nil {
return err
}
if err := BeforeCommit(tx, nil, true); err != nil {
return err
}
return tx.Commit()
},
}