mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
32 lines
536 B
Go
32 lines
536 B
Go
|
package db
|
||
|
|
||
|
import (
|
||
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||
|
)
|
||
|
|
||
|
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()
|
||
|
|
||
|
}
|