2020-05-22 01:36:26 +03:00
|
|
|
package migration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-04-26 20:08:11 +03:00
|
|
|
"github.com/lightningnetwork/lnd/kvdb"
|
2020-05-22 01:36:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// CreateTLB creates a new top-level bucket with the passed bucket identifier.
|
|
|
|
func CreateTLB(bucket []byte) func(kvdb.RwTx) error {
|
|
|
|
return func(tx kvdb.RwTx) error {
|
|
|
|
log.Infof("Creating top-level bucket: \"%s\" ...", bucket)
|
|
|
|
|
|
|
|
if tx.ReadBucket(bucket) != nil {
|
|
|
|
return fmt.Errorf("top-level bucket \"%s\" "+
|
|
|
|
"already exists", bucket)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := tx.CreateTopLevelBucket(bucket)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("Created top-level bucket: \"%s\"", bucket)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|