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