erigon-pulse/consensus/db/db.go
ledgerwatch 9690228ede
[Diagnostics] Simplify logging settings, introduce correct log rotation with lumberjack (#7273)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2023-04-07 21:08:44 +00:00

22 lines
410 B
Go

package db
import (
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
"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()
}