2021-04-19 21:58:05 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/ethdb"
|
2021-04-19 21:58:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func OpenDatabase(path string, inmem bool, mdbx bool) *ethdb.ObjectDatabase {
|
|
|
|
return ethdb.NewObjectDatabase(openKV(path, inmem, mdbx))
|
|
|
|
}
|
|
|
|
|
|
|
|
func openKV(path string, inmem bool, mdbx bool) ethdb.RwKV {
|
|
|
|
if mdbx {
|
|
|
|
opts := ethdb.NewMDBX()
|
|
|
|
if inmem {
|
|
|
|
opts = opts.InMem()
|
|
|
|
} else {
|
|
|
|
opts = opts.Path(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
return opts.MustOpen()
|
|
|
|
}
|
|
|
|
opts := ethdb.NewLMDB()
|
|
|
|
if inmem {
|
|
|
|
opts = opts.InMem()
|
|
|
|
} else {
|
|
|
|
opts = opts.Path(path)
|
|
|
|
}
|
|
|
|
|
|
|
|
return opts.MustOpen()
|
|
|
|
|
|
|
|
}
|