channeldb: fully initialize meta-data bucket during DB creation

This commit is contained in:
Olaoluwa Osuntokun 2016-11-27 18:48:57 -08:00
parent 7454b7df95
commit 5a668c9321
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -95,6 +95,7 @@ func Open(dbPath string, netParams *chaincfg.Params) (*DB, error) {
// database. The deletion is done in a single transaction, therefore this
// operation is fully atomic.
func (d *DB) Wipe() error {
return d.Update(func(tx *bolt.Tx) error {
err := tx.DeleteBucket(openChannelBucket)
if err != nil && err != bolt.ErrBucketNotFound {
return err
@ -157,7 +158,10 @@ func createChannelDB(dbPath string) error {
return err
}
return nil
meta := &Meta{
DbVersionNumber: getLatestDBVersion(dbVersions),
}
return putMeta(meta, tx)
})
if err != nil {
return fmt.Errorf("unable to create new channeldb")