2014-01-09 06:54:52 +01:00
|
|
|
// Copyright (c) 2013-2014 Conformal Systems LLC.
|
2013-10-13 08:59:55 +02:00
|
|
|
// 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-10-13 08:59:55 +02:00
|
|
|
)
|
|
|
|
|
2013-11-21 16:48:16 +01:00
|
|
|
var log = btclog.Disabled
|
2013-10-13 08:59:55 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|