channeldb: perform init of top level buckets first

This commit is contained in:
djkazic
2025-03-27 15:30:34 -04:00
committed by Olaoluwa Osuntokun
parent ff95646d42
commit 2ffcefc947

View File

@@ -479,6 +479,12 @@ func initChannelDB(db kvdb.Backend) error {
return err return err
} }
for _, tlb := range dbTopLevelBuckets {
if _, err := tx.CreateTopLevelBucket(tlb); err != nil {
return err
}
}
meta := &Meta{} meta := &Meta{}
// Check if DB is already initialized. // Check if DB is already initialized.
err := FetchMeta(meta, tx) err := FetchMeta(meta, tx)
@@ -486,12 +492,6 @@ func initChannelDB(db kvdb.Backend) error {
return nil return nil
} }
for _, tlb := range dbTopLevelBuckets {
if _, err := tx.CreateTopLevelBucket(tlb); err != nil {
return err
}
}
meta.DbVersionNumber = getLatestDBVersion(dbVersions) meta.DbVersionNumber = getLatestDBVersion(dbVersions)
return putMeta(meta, tx) return putMeta(meta, tx)
}, func() {}) }, func() {})