channeldb: ensure the edge index bucket is created during creation
Previously, the edge index bucket which maps a channelPoint -> channelID wasn’t properly created one start up during the initial creation of the database. This caused some extraneous failure as queries would unnecessarily fail with bucket non-existence errors. To fix this we now properly create the bucket on start up if the database doesn’t exist, and also properly delete the bucket within the Wipe() function.
This commit is contained in:
parent
f8711659e6
commit
68ed4f3661
@ -59,7 +59,7 @@ type DB struct {
|
||||
}
|
||||
|
||||
// Open opens an existing channeldb. Any necessary schemas migrations due to
|
||||
// udpates will take plave as necessary.
|
||||
// updates will take place as necessary.
|
||||
func Open(dbPath string) (*DB, error) {
|
||||
path := filepath.Join(dbPath, dbName)
|
||||
|
||||
@ -121,6 +121,10 @@ func (d *DB) Wipe() error {
|
||||
if err != nil && err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
}
|
||||
err = tx.DeleteBucket(edgeIndexBucket)
|
||||
if err != nil && err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
}
|
||||
err = tx.DeleteBucket(graphMetaBucket)
|
||||
if err != nil && err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
@ -170,6 +174,9 @@ func createChannelDB(dbPath string) error {
|
||||
if _, err := tx.CreateBucket(edgeBucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := tx.CreateBucket(edgeIndexBucket); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := tx.CreateBucket(graphMetaBucket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user