erigon-pulse/consensus/db/db.go

22 lines
410 B
Go
Raw Normal View History

package db
import (
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
2021-07-29 10:23:23 +00:00
"github.com/ledgerwatch/log/v3"
)
func OpenDatabase(path string, inMem bool, readonly bool) kv.RwDB {
opts := mdbx.NewMDBX(log.Root()).Label(kv.ConsensusDB)
if readonly {
opts = opts.Readonly()
}
if inMem {
opts = opts.InMem("")
} else {
opts = opts.Path(path)
}
return opts.MustOpen()
}