diff --git a/db/backend_test.go b/db/backend_test.go index 9e73a1f66..80fbbb140 100644 --- a/db/backend_test.go +++ b/db/backend_test.go @@ -15,7 +15,7 @@ func cleanupDBDir(dir, name string) { os.RemoveAll(filepath.Join(dir, name) + ".db") } -func testBackendGetSetDelete(t *testing.T, backend DbBackendType) { +func testBackendGetSetDelete(t *testing.T, backend DBBackendType) { // Default dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend)) defer dir.Close() diff --git a/db/common_test.go b/db/common_test.go index 4209b44d7..1b0f00416 100644 --- a/db/common_test.go +++ b/db/common_test.go @@ -45,7 +45,7 @@ func checkValuePanics(t *testing.T, itr Iterator) { assert.Panics(t, func() { itr.Key() }, "checkValuePanics expected panic but didn't") } -func newTempDB(t *testing.T, backend DbBackendType) (db DB) { +func newTempDB(t *testing.T, backend DBBackendType) (db DB) { dir, dirname := cmn.Tempdir("test_go_iterator") db = NewDB("testdb", backend, dirname) dir.Close() diff --git a/db/db.go b/db/db.go index ac19f6b4b..869937660 100644 --- a/db/db.go +++ b/db/db.go @@ -5,21 +5,21 @@ import "fmt" //---------------------------------------- // Main entry -type DbBackendType string +type DBBackendType string const ( - LevelDBBackend DbBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc - CLevelDBBackend DbBackendType = "cleveldb" - GoLevelDBBackend DbBackendType = "goleveldb" - MemDBBackend DbBackendType = "memdb" - FSDBBackend DbBackendType = "fsdb" // using the filesystem naively + LevelDBBackend DBBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc + CLevelDBBackend DBBackendType = "cleveldb" + GoLevelDBBackend DBBackendType = "goleveldb" + MemDBBackend DBBackendType = "memdb" + FSDBBackend DBBackendType = "fsdb" // using the filesystem naively ) type dbCreator func(name string, dir string) (DB, error) -var backends = map[DbBackendType]dbCreator{} +var backends = map[DBBackendType]dbCreator{} -func registerDBCreator(backend DbBackendType, creator dbCreator, force bool) { +func registerDBCreator(backend DBBackendType, creator dbCreator, force bool) { _, ok := backends[backend] if !force && ok { return @@ -27,7 +27,7 @@ func registerDBCreator(backend DbBackendType, creator dbCreator, force bool) { backends[backend] = creator } -func NewDB(name string, backend DbBackendType, dir string) DB { +func NewDB(name string, backend DBBackendType, dir string) DB { db, err := backends[backend](name, dir) if err != nil { panic(fmt.Sprintf("Error initializing DB: %v", err))