lbcd/memdb/driver.go

30 lines
734 B
Go
Raw Normal View History

2014-01-09 06:54:52 +01:00
// 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"
2013-11-21 16:48:16 +01:00
"github.com/conformal/btclog"
)
2013-11-21 16:48:16 +01:00
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
}