erigon-pulse/node/nodecfg/datadir/dirs.go
Andrew Ashikhmin 7286a0fef7
Create in-memory MDBX inside dirs.Tmp (#5702)
Previously "in-memory" MDBX instances for fork validation and mining
were created inside `os.TempDir()`. We should create them inside
Erigon's datadir so that the file permissions and the disk are the same
as for the main database.

Prerequisite: https://github.com/ledgerwatch/erigon-lib/pull/676.
2022-10-11 16:49:38 +01:00

44 lines
1.2 KiB
Go

package datadir
import (
"path/filepath"
)
// Dirs is the file system folder the node should use for any data storage
// requirements. The configured data directory will not be directly shared with
// registered services, instead those can use utility methods to create/access
// databases or flat files
type Dirs struct {
DataDir string
RelativeDataDir string // like dataDir, but without filepath.Abs() resolution
Chaindata string
Tmp string
Snap string
SnapHistory string
TxPool string
Nodes string
}
func New(datadir string) Dirs {
relativeDataDir := datadir
if datadir != "" {
var err error
absdatadir, err := filepath.Abs(datadir)
if err != nil {
panic(err)
}
datadir = absdatadir
}
return Dirs{
RelativeDataDir: relativeDataDir,
DataDir: datadir,
Chaindata: filepath.Join(datadir, "chaindata"),
Tmp: filepath.Join(datadir, "temp"),
Snap: filepath.Join(datadir, "snapshots"),
SnapHistory: filepath.Join(datadir, "snapshots", "history"),
TxPool: filepath.Join(datadir, "txpool"),
Nodes: filepath.Join(datadir, "nodes"),
}
}