channeldb: fix bucket creation hierarchy in createChannelDB

In this commit, we fix a bug in the bucket creation code in
createChannelDB. This bug can cause migrations on older nodes to fail,
as we expect the bucket to already have been created. With this commit,
we ensure that all the buckets under the main node and edges bucket are
properly created. Otherwise, a set of the newer migrations will fail to
apply for nodes updating from 0.4.
This commit is contained in:
Olaoluwa Osuntokun 2018-09-09 15:49:21 -07:00
parent 874002022f
commit 3e67321aa7
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -201,29 +201,63 @@ func createChannelDB(dbPath string) error {
if _, err := tx.CreateBucket(openChannelBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(closedChannelBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(forwardingLogBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(fwdPackagesKey); err != nil {
return err
}
if _, err := tx.CreateBucket(invoiceBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(paymentBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(nodeInfoBucket); err != nil {
return err
}
if _, err := tx.CreateBucket(nodeBucket); err != nil {
nodes, err := tx.CreateBucket(nodeBucket)
if err != nil {
return err
}
if _, err := tx.CreateBucket(edgeBucket); err != nil {
_, err = nodes.CreateBucket(aliasIndexBucket)
if err != nil {
return err
}
if _, err := tx.CreateBucket(edgeIndexBucket); err != nil {
_, err = nodes.CreateBucket(nodeUpdateIndexBucket)
if err != nil {
return err
}
if _, err := tx.CreateBucket(graphMetaBucket); err != nil {
edges, err := tx.CreateBucket(edgeBucket)
if err != nil {
return err
}
if _, err := edges.CreateBucket(edgeIndexBucket); err != nil {
return err
}
if _, err := edges.CreateBucket(edgeUpdateIndexBucket); err != nil {
return err
}
if _, err := edges.CreateBucket(channelPointBucket); err != nil {
return err
}
graphMeta, err := tx.CreateBucket(graphMetaBucket)
if err != nil {
return err
}
_, err = graphMeta.CreateBucket(pruneLogBucket)
if err != nil {
return err
}