lbcd/memdb/driver.go
2014-01-08 23:54:52 -06:00

29 lines
734 B
Go

// Copyright (c) 2013-2014 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package memdb
import (
"github.com/conformal/btcdb"
"github.com/conformal/btclog"
)
var log = btclog.Disabled
func init() {
driver := btcdb.DriverDB{DbType: "memdb", Create: CreateDB, Open: OpenDB}
btcdb.AddDBDriver(driver)
}
// OpenDB opens an existing database for use.
func OpenDB(dbpath string) (btcdb.Db, error) {
// A memory database is not persistent, so let CreateDB handle it.
return CreateDB(dbpath)
}
// CreateDB creates, initializes, and opens a database for use.
func CreateDB(dbpath string) (btcdb.Db, error) {
log = btcdb.GetLog()
return newMemDb(), nil
}