erigon-pulse/consensus/db/db.go

22 lines
425 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, logger log.Logger, inMem bool, readonly bool) kv.RwDB {
2022-01-22 05:53:25 +00:00
opts := mdbx.NewMDBX(logger).Label(kv.ConsensusDB)
if readonly {
opts = opts.Readonly()
}
if inMem {
opts = opts.InMem("")
} else {
opts = opts.Path(path)
}
return opts.MustOpen()
}