mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
path -> filepath (path package is for urls) (#3493)
This commit is contained in:
parent
479c7f3d9d
commit
c9cee7a884
@ -9,7 +9,6 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@ -95,7 +94,7 @@ func BuildTorrentFilesIfNeed(ctx context.Context, root string) error {
|
||||
return err
|
||||
}
|
||||
for i, f := range files {
|
||||
torrentFileName := path.Join(root, f+".torrent")
|
||||
torrentFileName := filepath.Join(root, f+".torrent")
|
||||
if _, err := os.Stat(torrentFileName); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@ -103,7 +102,7 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func Downloader(ctx context.Context) error {
|
||||
snapshotDir := path.Join(datadir, "snapshots")
|
||||
snapshotDir := filepath.Join(datadir, "snapshots")
|
||||
common.MustExist(snapshotDir)
|
||||
torrentLogLevel, ok := torrentcfg.String2LogLevel[torrentVerbosity]
|
||||
if !ok {
|
||||
@ -157,7 +156,7 @@ var printTorrentHashes = &cobra.Command{
|
||||
Use: "torrent_hashes",
|
||||
Example: "go run ./cmd/downloader torrent_hashes --datadir <your_datadir>",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
snapshotDir := path.Join(datadir, "snapshots")
|
||||
snapshotDir := filepath.Join(datadir, "snapshots")
|
||||
ctx := cmd.Context()
|
||||
|
||||
if forceVerify { // remove and create .torrent files (will re-read all snapshots)
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands"
|
||||
@ -348,7 +349,7 @@ func saveFile(baseDir, filename string, data interface{}) error {
|
||||
if err != nil {
|
||||
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
|
||||
}
|
||||
location := path.Join(baseDir, filename)
|
||||
location := filepath.Join(baseDir, filename)
|
||||
if err = ioutil.WriteFile(location, b, 0644); err != nil { //nolint:gosec
|
||||
return NewError(ErrorIO, fmt.Errorf("failed writing output: %v", err))
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
@ -384,7 +384,7 @@ func (m *mdbx_meta) readMeta(page []byte) error {
|
||||
m.txnID_b = _64(page, pos)
|
||||
pos += 8
|
||||
|
||||
pos += (3 * 8) // pagesRetired, x, y
|
||||
pos += 3 * 8 // pagesRetired, x, y
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -941,7 +941,7 @@ func Defrag() error {
|
||||
func TextInfo(chaindata string, visStream io.Writer) error {
|
||||
log.Info("Text Info", "db", chaindata)
|
||||
fmt.Fprint(visStream, "digraph lmdb {\nrankdir=LR\n")
|
||||
datafile := path.Join(chaindata, MdbxDataFile)
|
||||
datafile := filepath.Join(chaindata, MdbxDataFile)
|
||||
|
||||
f, err := os.Open(datafile)
|
||||
if err != nil {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
@ -20,7 +20,7 @@ var rootCmd = &cobra.Command{
|
||||
panic(err)
|
||||
}
|
||||
if chaindata == "" {
|
||||
chaindata = path.Join(datadir, "chaindata")
|
||||
chaindata = filepath.Join(datadir, "chaindata")
|
||||
}
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -490,7 +490,7 @@ func stageBodies(db kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageSenders(db kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
_, _, chainConfig, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
|
||||
must(sync.SetCurrentStage(stages.Senders))
|
||||
@ -572,7 +572,7 @@ func stageSenders(db kv.RwDB, ctx context.Context) error {
|
||||
func stageExec(db kv.RwDB, ctx context.Context) error {
|
||||
pm, engine, chainConfig, vmConfig, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.Execution))
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
if reset {
|
||||
genesis, _ := byChain()
|
||||
@ -632,7 +632,7 @@ func stageExec(db kv.RwDB, ctx context.Context) error {
|
||||
func stageTrie(db kv.RwDB, ctx context.Context) error {
|
||||
pm, _, chainConfig, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.IntermediateHashes))
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
tx, err := db.BeginRw(ctx)
|
||||
if err != nil {
|
||||
@ -684,7 +684,7 @@ func stageTrie(db kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageHashState(db kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
pm, _, _, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.HashState))
|
||||
@ -738,7 +738,7 @@ func stageHashState(db kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageLogIndex(db kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
pm, _, _, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.LogIndex))
|
||||
@ -793,7 +793,7 @@ func stageLogIndex(db kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageCallTraces(kv kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
pm, _, _, _, sync, _, _ := newSync(ctx, kv, nil)
|
||||
must(sync.SetCurrentStage(stages.CallTraces))
|
||||
@ -854,7 +854,7 @@ func stageCallTraces(kv kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageHistory(db kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
pm, _, _, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.AccountHistoryIndex))
|
||||
|
||||
@ -924,7 +924,7 @@ func stageHistory(db kv.RwDB, ctx context.Context) error {
|
||||
}
|
||||
|
||||
func stageTxLookup(db kv.RwDB, ctx context.Context) error {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
pm, _, chainConfig, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
must(sync.SetCurrentStage(stages.TxLookup))
|
||||
@ -1059,7 +1059,7 @@ func allSnapshots(cc *params.ChainConfig) *snapshotsync.AllSnapshots {
|
||||
openSnapshotOnce.Do(func() {
|
||||
if enableSnapshot {
|
||||
snapshotCfg := ethconfig.NewSnapshotCfg(true, false)
|
||||
_allSnapshotsSingleton = snapshotsync.NewAllSnapshots(snapshotCfg, path.Join(datadir, "snapshots"))
|
||||
_allSnapshotsSingleton = snapshotsync.NewAllSnapshots(snapshotCfg, filepath.Join(datadir, "snapshots"))
|
||||
if err := _allSnapshotsSingleton.ReopenSegments(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -1080,7 +1080,7 @@ func getBlockReader(cc *params.ChainConfig) (blockReader interfaces.FullBlockRea
|
||||
}
|
||||
|
||||
func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig) (prune.Mode, consensus.Engine, *params.ChainConfig, *vm.Config, *stagedsync.Sync, *stagedsync.Sync, stagedsync.MiningState) {
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
logger := log.New()
|
||||
|
||||
var pm prune.Mode
|
||||
@ -1104,12 +1104,12 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig)
|
||||
config := ðconfig.Defaults
|
||||
if chainConfig.Clique != nil {
|
||||
c := params.CliqueSnapshot
|
||||
c.DBPath = path.Join(datadir, "clique/db")
|
||||
c.DBPath = filepath.Join(datadir, "clique", "db")
|
||||
engine = ethconfig.CreateConsensusEngine(chainConfig, logger, c, config.Miner.Notify, config.Miner.Noverify, "", true, datadir)
|
||||
} else if chainConfig.Aura != nil {
|
||||
engine = ethconfig.CreateConsensusEngine(chainConfig, logger, ¶ms.AuRaConfig{DBPath: path.Join(datadir, "aura")}, config.Miner.Notify, config.Miner.Noverify, "", true, datadir)
|
||||
engine = ethconfig.CreateConsensusEngine(chainConfig, logger, ¶ms.AuRaConfig{DBPath: filepath.Join(datadir, "aura")}, config.Miner.Notify, config.Miner.Noverify, "", true, datadir)
|
||||
} else if chainConfig.Parlia != nil {
|
||||
consensusConfig := ¶ms.ParliaConfig{DBPath: path.Join(datadir, "parlia")}
|
||||
consensusConfig := ¶ms.ParliaConfig{DBPath: filepath.Join(datadir, "parlia")}
|
||||
engine = ethconfig.CreateConsensusEngine(chainConfig, logger, consensusConfig, config.Miner.Notify, config.Miner.Noverify, "", true, datadir)
|
||||
} else { //ethash
|
||||
engine = ethash.NewFaker()
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@ -154,7 +155,7 @@ func syncBySmallSteps(db kv.RwDB, miningConfig params.MiningConfig, ctx context.
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
tmpDir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpDir := filepath.Join(datadir, etl.TmpDirName)
|
||||
quit := ctx.Done()
|
||||
|
||||
var batchSize datasize.ByteSize
|
||||
@ -409,7 +410,7 @@ func checkMinedBlock(b1, b2 *types.Block, chainConfig *params.ChainConfig) {
|
||||
|
||||
func loopIh(db kv.RwDB, ctx context.Context, unwind uint64) error {
|
||||
_, _, chainConfig, _, sync, _, _ := newSync(ctx, db, nil)
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
tx, err := db.BeginRw(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -474,7 +475,7 @@ func loopIh(db kv.RwDB, ctx context.Context, unwind uint64) error {
|
||||
|
||||
func loopExec(db kv.RwDB, ctx context.Context, unwind uint64) error {
|
||||
pm, engine, chainConfig, vmConfig, sync, _, _ := newSync(ctx, db, nil)
|
||||
tmpdir := path.Join(datadir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(datadir, etl.TmpDirName)
|
||||
|
||||
tx, err := db.BeginRw(ctx)
|
||||
if err != nil {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -138,7 +138,7 @@ func RootCommand() (*cobra.Command, *Flags) {
|
||||
cfg.Datadir = paths.DefaultDataDir()
|
||||
}
|
||||
if cfg.Chaindata == "" {
|
||||
cfg.Chaindata = path.Join(cfg.Datadir, "chaindata")
|
||||
cfg.Chaindata = filepath.Join(cfg.Datadir, "chaindata")
|
||||
}
|
||||
cfg.Snapshot = ethconfig.NewSnapshotCfg(cfg.Snapshot.Enabled, cfg.Snapshot.RetireEnabled)
|
||||
}
|
||||
@ -290,7 +290,7 @@ func RemoteServices(ctx context.Context, cfg Flags, logger log.Logger, rootCance
|
||||
|
||||
// bor (consensus) specific db
|
||||
var borKv kv.RoDB
|
||||
borDbPath := path.Join(cfg.Datadir, "bor")
|
||||
borDbPath := filepath.Join(cfg.Datadir, "bor")
|
||||
{
|
||||
// ensure db exist
|
||||
tmpDb, err := kv2.NewMDBX(logger).Path(borDbPath).Label(kv.ConsensusDB).Open()
|
||||
@ -335,7 +335,7 @@ func RemoteServices(ctx context.Context, cfg Flags, logger log.Logger, rootCance
|
||||
return nil, nil, nil, nil, nil, nil, nil, nil, ff, fmt.Errorf("chain config not found in db. Need start erigon at least once on this db")
|
||||
}
|
||||
|
||||
allSnapshots := snapshotsync.NewAllSnapshots(cfg.Snapshot, path.Join(cfg.Datadir, "snapshots"))
|
||||
allSnapshots := snapshotsync.NewAllSnapshots(cfg.Snapshot, filepath.Join(cfg.Datadir, "snapshots"))
|
||||
allSnapshots.AsyncOpenAll(ctx)
|
||||
blockReader = snapshotsync.NewBlockReaderWithSnapshots(allSnapshots)
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
@ -357,14 +357,14 @@ func vegetaWrite(enabled bool, methods []string, resultsCh chan CallResult) {
|
||||
}
|
||||
tmpDir := os.TempDir()
|
||||
fmt.Printf("tmp dir is: %s\n", tmpDir)
|
||||
dir := path.Join(tmpDir, "erigon_stress_test")
|
||||
dir := filepath.Join(tmpDir, "erigon_stress_test")
|
||||
if err = os.MkdirAll(dir, 0770); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, route := range []string{Geth, Erigon} {
|
||||
for _, method := range methods {
|
||||
file := path.Join(dir, "results_"+route+"_"+method+".csv")
|
||||
file := filepath.Join(dir, "results_"+route+"_"+method+".csv")
|
||||
files[route][method], err = os.OpenFile(file, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -374,7 +374,7 @@ func vegetaWrite(enabled bool, methods []string, resultsCh chan CallResult) {
|
||||
|
||||
for _, route := range []string{Geth, Erigon} {
|
||||
for _, method := range methods {
|
||||
file := path.Join(dir, "vegeta_"+route+"_"+method+".txt")
|
||||
file := filepath.Join(dir, "vegeta_"+route+"_"+method+".txt")
|
||||
vegetaFiles[route][method], err = os.OpenFile(file, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
|
||||
@ -68,7 +68,7 @@ var rootCmd = &cobra.Command{
|
||||
panic(err)
|
||||
}
|
||||
if chaindata == "" {
|
||||
chaindata = path.Join(datadir, "chaindata")
|
||||
chaindata = filepath.Join(datadir, "chaindata")
|
||||
}
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
|
@ -3,15 +3,16 @@ package cmd
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
"github.com/ledgerwatch/erigon/cmd/starknet/services"
|
||||
"github.com/ledgerwatch/erigon/common/paths"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -107,7 +108,7 @@ func config() (*cobra.Command, *Flags) {
|
||||
flags.Datadir = paths.DefaultDataDir()
|
||||
}
|
||||
if flags.Chaindata == "" {
|
||||
flags.Chaindata = path.Join(flags.Datadir, "chaindata")
|
||||
flags.Chaindata = filepath.Join(flags.Datadir, "chaindata")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -86,7 +87,7 @@ func Erigon2(genesis *core.Genesis, logger log.Logger) error {
|
||||
return err1
|
||||
}
|
||||
defer historyTx.Rollback()
|
||||
aggPath := path.Join(datadir, "aggregator")
|
||||
aggPath := filepath.Join(datadir, "aggregator")
|
||||
if block == 0 {
|
||||
if _, err = os.Stat(aggPath); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -60,7 +61,7 @@ func History2(genesis *core.Genesis, logger log.Logger) error {
|
||||
return err1
|
||||
}
|
||||
defer historyTx.Rollback()
|
||||
aggPath := path.Join(datadir, "aggregator")
|
||||
aggPath := filepath.Join(datadir, "aggregator")
|
||||
h, err3 := aggregator.NewHistory(aggPath, 499_999, aggregationStep)
|
||||
if err3 != nil {
|
||||
return fmt.Errorf("create history: %w", err3)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon/cmd/utils"
|
||||
@ -36,7 +36,7 @@ var rootCmd = &cobra.Command{
|
||||
genesis = genesisFromFile(genesisPath)
|
||||
}
|
||||
if chaindata == "" {
|
||||
chaindata = path.Join(datadir, "chaindata")
|
||||
chaindata = filepath.Join(datadir, "chaindata")
|
||||
}
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
@ -59,7 +60,7 @@ func StateRoot(genesis *core.Genesis, logger log.Logger, blockNum uint64, datadi
|
||||
return err1
|
||||
}
|
||||
defer historyTx.Rollback()
|
||||
stateDbPath := path.Join(datadir, "staterootdb")
|
||||
stateDbPath := filepath.Join(datadir, "staterootdb")
|
||||
if _, err = os.Stat(stateDbPath); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
@ -94,7 +94,7 @@ var rootCmd = &cobra.Command{
|
||||
return fmt.Errorf("could not connect to remoteKv: %w", err)
|
||||
}
|
||||
|
||||
log.Info("TxPool started", "db", path.Join(datadir, "txpool"))
|
||||
log.Info("TxPool started", "db", filepath.Join(datadir, "txpool"))
|
||||
|
||||
sentryClients := make([]direct.SentryClient, len(sentryAddr))
|
||||
for i := range sentryAddr {
|
||||
@ -111,7 +111,7 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
cfg := txpool.DefaultConfig
|
||||
cfg.DBDir = path.Join(datadir, "txpool")
|
||||
cfg.DBDir = filepath.Join(datadir, "txpool")
|
||||
cfg.LogEvery = 30 * time.Second
|
||||
cfg.CommitEvery = 30 * time.Second
|
||||
cfg.PendingSubPoolLimit = pendingPoolLimit
|
||||
|
@ -796,11 +796,11 @@ func NewP2PConfig(nodiscover bool, datadir, netRestrict, natSetting, nodeName st
|
||||
var enodeDBPath string
|
||||
switch protocol {
|
||||
case eth.ETH66:
|
||||
enodeDBPath = path.Join(datadir, "nodes", "eth66")
|
||||
enodeDBPath = filepath.Join(datadir, "nodes", "eth66")
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown protocol: %v", protocol)
|
||||
}
|
||||
serverKey := nodeKey(path.Join(datadir, "nodekey"))
|
||||
serverKey := nodeKey(filepath.Join(datadir, "nodekey"))
|
||||
|
||||
cfg := &p2p.Config{
|
||||
ListenAddr: fmt.Sprintf(":%d", port),
|
||||
@ -1160,7 +1160,7 @@ func setEthash(ctx *cli.Context, datadir string, cfg *ethconfig.Config) {
|
||||
if ctx.GlobalIsSet(EthashDatasetDirFlag.Name) {
|
||||
cfg.Ethash.DatasetDir = ctx.GlobalString(EthashDatasetDirFlag.Name)
|
||||
} else {
|
||||
cfg.Ethash.DatasetDir = path.Join(datadir, "ethash-dags")
|
||||
cfg.Ethash.DatasetDir = filepath.Join(datadir, "ethash-dags")
|
||||
}
|
||||
if ctx.GlobalIsSet(EthashCachesInMemoryFlag.Name) {
|
||||
cfg.Ethash.CachesInMem = ctx.GlobalInt(EthashCachesInMemoryFlag.Name)
|
||||
@ -1232,18 +1232,18 @@ func setClique(ctx *cli.Context, cfg *params.ConsensusSnapshotConfig, datadir st
|
||||
cfg.InmemorySnapshots = ctx.GlobalInt(CliqueSnapshotInmemorySnapshotsFlag.Name)
|
||||
cfg.InmemorySignatures = ctx.GlobalInt(CliqueSnapshotInmemorySignaturesFlag.Name)
|
||||
if ctx.GlobalIsSet(CliqueDataDirFlag.Name) {
|
||||
cfg.DBPath = path.Join(ctx.GlobalString(CliqueDataDirFlag.Name), "clique/db")
|
||||
cfg.DBPath = filepath.Join(ctx.GlobalString(CliqueDataDirFlag.Name), "clique", "db")
|
||||
} else {
|
||||
cfg.DBPath = path.Join(datadir, "clique/db")
|
||||
cfg.DBPath = filepath.Join(datadir, "clique", "db")
|
||||
}
|
||||
}
|
||||
|
||||
func setAuRa(ctx *cli.Context, cfg *params.AuRaConfig, datadir string) {
|
||||
cfg.DBPath = path.Join(datadir, "aura")
|
||||
cfg.DBPath = filepath.Join(datadir, "aura")
|
||||
}
|
||||
|
||||
func setParlia(ctx *cli.Context, cfg *params.ParliaConfig, datadir string) {
|
||||
cfg.DBPath = path.Join(datadir, "parlia")
|
||||
cfg.DBPath = filepath.Join(datadir, "parlia")
|
||||
}
|
||||
|
||||
func setBorConfig(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||
@ -1344,7 +1344,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
|
||||
|
||||
// SetEthConfig applies eth-related command line flags to the config.
|
||||
func SetEthConfig(ctx *cli.Context, nodeConfig *node.Config, cfg *ethconfig.Config) {
|
||||
cfg.SnapshotDir = path.Join(nodeConfig.DataDir, "snapshots")
|
||||
cfg.SnapshotDir = filepath.Join(nodeConfig.DataDir, "snapshots")
|
||||
if ctx.GlobalBool(SnapshotSyncFlag.Name) {
|
||||
cfg.Snapshot.Enabled = true
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -153,7 +153,7 @@ func New(stack *node.Node, config *ethconfig.Config, txpoolCfg txpool2.Config, l
|
||||
config.Miner.GasPrice = new(big.Int).Set(ethconfig.Defaults.Miner.GasPrice)
|
||||
}
|
||||
|
||||
tmpdir := path.Join(stack.Config().DataDir, etl.TmpDirName)
|
||||
tmpdir := filepath.Join(stack.Config().DataDir, etl.TmpDirName)
|
||||
if err := os.RemoveAll(tmpdir); err != nil { // clean it on startup
|
||||
return nil, fmt.Errorf("clean tmp dir: %s, %w", tmpdir, err)
|
||||
}
|
||||
@ -281,7 +281,7 @@ func New(stack *node.Node, config *ethconfig.Config, txpoolCfg txpool2.Config, l
|
||||
}
|
||||
|
||||
cfg66 := stack.Config().P2P
|
||||
cfg66.NodeDatabase = path.Join(stack.Config().DataDir, "nodes", "eth66")
|
||||
cfg66.NodeDatabase = filepath.Join(stack.Config().DataDir, "nodes", "eth66")
|
||||
server66 := sentry.NewSentryServer(backend.sentryCtx, d66, readNodeInfo, &cfg66, eth.ETH66)
|
||||
backend.sentryServers = append(backend.sentryServers, server66)
|
||||
backend.sentries = []direct.SentryClient{direct.NewSentryClientDirect(eth.ETH66, server66)}
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"math/big"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -267,7 +266,7 @@ func CreateConsensusEngine(chainConfig *params.ChainConfig, logger log.Logger, c
|
||||
}
|
||||
case *params.BorConfig:
|
||||
if chainConfig.Bor != nil {
|
||||
borDbPath := path.Join(dataDir, "bor") // bor consensus path: datadir/bor
|
||||
borDbPath := filepath.Join(dataDir, "bor") // bor consensus path: datadir/bor
|
||||
eng = bor.New(chainConfig, db.OpenDatabase(borDbPath, logger, false), HeimdallURL, WithoutHeimdall)
|
||||
}
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -40,7 +40,7 @@ require (
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/kevinburke/go-bindata v3.21.0+incompatible
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212114842-31982dacc8a5
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212125515-3442f42457cb
|
||||
github.com/ledgerwatch/log/v3 v3.4.0
|
||||
github.com/ledgerwatch/secp256k1 v1.0.0
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
|
||||
|
4
go.sum
4
go.sum
@ -632,8 +632,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P
|
||||
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212114842-31982dacc8a5 h1:P8LFJVTTfh3s+vjWa8g7tK8MyEF0fuIz+36Ksj1iAz8=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212114842-31982dacc8a5/go.mod h1:phuzMr8tLvqjo5cQVA9jj8odAso6eLyS4LFmUJrDFGw=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212125515-3442f42457cb h1:kzS/0e5EHNBeFGybHt2zboOlDeoPydFfjQqBvGhCt8c=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20220212125515-3442f42457cb/go.mod h1:phuzMr8tLvqjo5cQVA9jj8odAso6eLyS4LFmUJrDFGw=
|
||||
github.com/ledgerwatch/log/v3 v3.4.0 h1:SEIOcv5a2zkG3PmoT5jeTU9m/0nEUv0BJS5bzsjwKCI=
|
||||
github.com/ledgerwatch/log/v3 v3.4.0/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY=
|
||||
github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=
|
||||
|
@ -161,7 +161,7 @@ func UploadSFTP(identityFile, host, dir string, files []string) error {
|
||||
}
|
||||
in := io.MultiWriter(stdin, os.Stdout)
|
||||
for _, f := range files {
|
||||
fmt.Fprintln(in, "put", f, path.Join(dir, filepath.Base(f)))
|
||||
fmt.Fprintln(in, "put", f, filepath.Join(dir, filepath.Base(f)))
|
||||
}
|
||||
stdin.Close()
|
||||
return sftp.Wait()
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
@ -184,7 +184,7 @@ func (m *Migrator) Apply(db kv.RwDB, datadir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := v.Up(db, path.Join(datadir, "migrations", v.Name), progress, func(tx kv.RwTx, key []byte, isDone bool) error {
|
||||
if err := v.Up(db, filepath.Join(datadir, "migrations", v.Name), progress, func(tx kv.RwTx, key []byte, isDone bool) error {
|
||||
if !isDone {
|
||||
if key != nil {
|
||||
if err := tx.Put(kv.Migrations, []byte("_progress_"+v.Name), key); err != nil {
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
@ -82,8 +83,8 @@ func doIndicesCommand(cliCtx *cli.Context) error {
|
||||
defer cancel()
|
||||
|
||||
dataDir := cliCtx.String(utils.DataDirFlag.Name)
|
||||
snapshotDir := path.Join(dataDir, "snapshots")
|
||||
tmpDir := path.Join(dataDir, etl.TmpDirName)
|
||||
snapshotDir := filepath.Join(dataDir, "snapshots")
|
||||
tmpDir := filepath.Join(dataDir, etl.TmpDirName)
|
||||
rebuild := cliCtx.Bool(SnapshotRebuildFlag.Name)
|
||||
from := cliCtx.Uint64(SnapshotFromFlag.Name)
|
||||
|
||||
@ -110,11 +111,11 @@ func doSnapshotCommand(cliCtx *cli.Context) error {
|
||||
return fmt.Errorf("too small --segment.size %d", segmentSize)
|
||||
}
|
||||
dataDir := cliCtx.String(utils.DataDirFlag.Name)
|
||||
snapshotDir := path.Join(dataDir, "snapshots")
|
||||
tmpDir := path.Join(dataDir, etl.TmpDirName)
|
||||
snapshotDir := filepath.Join(dataDir, "snapshots")
|
||||
tmpDir := filepath.Join(dataDir, etl.TmpDirName)
|
||||
common.MustExist(tmpDir)
|
||||
|
||||
chainDB := mdbx.NewMDBX(log.New()).Path(path.Join(dataDir, "chaindata")).Readonly().MustOpen()
|
||||
chainDB := mdbx.NewMDBX(log.New()).Path(filepath.Join(dataDir, "chaindata")).Readonly().MustOpen()
|
||||
defer chainDB.Close()
|
||||
|
||||
if err := snapshotBlocks(ctx, chainDB, fromBlock, toBlock, segmentSize, snapshotDir, tmpDir); err != nil {
|
||||
@ -200,7 +201,7 @@ func checkBlockSnapshot(chaindata string) error {
|
||||
_ = chainID
|
||||
|
||||
cfg := ethconfig.NewSnapshotCfg(true, true)
|
||||
snapshots := snapshotsync.NewAllSnapshots(cfg, path.Join(dataDir, "snapshots"))
|
||||
snapshots := snapshotsync.NewAllSnapshots(cfg, filepath.Join(dataDir, "snapshots"))
|
||||
snapshots.ReopenSegments()
|
||||
snapshots.ReopenIndices()
|
||||
//if err := snapshots.BuildIndices(context.Background(), *chainID); err != nil {
|
||||
|
@ -2,7 +2,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
@ -116,7 +116,7 @@ func New(
|
||||
// RegisterEthService adds an Ethereum client to the stack.
|
||||
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, logger log.Logger) (*eth.Ethereum, error) {
|
||||
txpoolCfg := core.DefaultTxPool2Config(cfg.TxPool)
|
||||
txpoolCfg.DBDir = path.Join(stack.Config().DataDir, "txpool")
|
||||
txpoolCfg.DBDir = filepath.Join(stack.Config().DataDir, "txpool")
|
||||
|
||||
return eth.New(stack, cfg, txpoolCfg, logger)
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ func (s *AllSnapshots) BuildIndices(ctx context.Context, chainID uint256.Int, tm
|
||||
if sn.From < from {
|
||||
continue
|
||||
}
|
||||
f := path.Join(s.dir, SegmentFileName(sn.From, sn.To, Headers))
|
||||
f := filepath.Join(s.dir, SegmentFileName(sn.From, sn.To, Headers))
|
||||
if err := HeadersHashIdx(ctx, f, sn.From, tmpDir, logEvery); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -335,7 +335,7 @@ func (s *AllSnapshots) BuildIndices(ctx context.Context, chainID uint256.Int, tm
|
||||
if sn.From < from {
|
||||
continue
|
||||
}
|
||||
f := path.Join(s.dir, SegmentFileName(sn.From, sn.To, Bodies))
|
||||
f := filepath.Join(s.dir, SegmentFileName(sn.From, sn.To, Bodies))
|
||||
if err := BodiesIdx(ctx, f, sn.From, tmpDir, logEvery); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -369,7 +369,7 @@ func (s *AllSnapshots) BuildIndices(ctx context.Context, chainID uint256.Int, tm
|
||||
}
|
||||
expectedTxsAmount = lastBody.BaseTxId + uint64(lastBody.TxAmount) - firstBody.BaseTxId
|
||||
}
|
||||
f := path.Join(s.dir, SegmentFileName(sn.From, sn.To, Transactions))
|
||||
f := filepath.Join(s.dir, SegmentFileName(sn.From, sn.To, Transactions))
|
||||
if err := TransactionsHashIdx(ctx, chainID, sn, firstBody.BaseTxId, sn.From, expectedTxsAmount, f, tmpDir, logEvery); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -802,7 +802,7 @@ func TransactionsHashIdx(ctx context.Context, chainID uint256.Int, sn *BlocksSna
|
||||
Salt: 0,
|
||||
LeafSize: 8,
|
||||
TmpDir: tmpDir,
|
||||
IndexFile: path.Join(dir, IdxFileName(sn.From, sn.To, Transactions)),
|
||||
IndexFile: filepath.Join(dir, IdxFileName(sn.From, sn.To, Transactions)),
|
||||
BaseDataID: firstTxID,
|
||||
})
|
||||
if err != nil {
|
||||
@ -815,7 +815,7 @@ func TransactionsHashIdx(ctx context.Context, chainID uint256.Int, sn *BlocksSna
|
||||
Salt: 0,
|
||||
LeafSize: 8,
|
||||
TmpDir: tmpDir,
|
||||
IndexFile: path.Join(dir, IdxFileName(sn.From, sn.To, Transactions2Block)),
|
||||
IndexFile: filepath.Join(dir, IdxFileName(sn.From, sn.To, Transactions2Block)),
|
||||
BaseDataID: firstBlockNum,
|
||||
})
|
||||
if err != nil {
|
||||
@ -1129,11 +1129,11 @@ func assertAllSegments(blocks []*BlocksSnapshot, root string) {
|
||||
wg.Add(1)
|
||||
go func(sn *BlocksSnapshot) {
|
||||
defer wg.Done()
|
||||
f := path.Join(root, SegmentFileName(sn.From, sn.To, Headers))
|
||||
f := filepath.Join(root, SegmentFileName(sn.From, sn.To, Headers))
|
||||
assertSegment(f)
|
||||
f = path.Join(root, SegmentFileName(sn.From, sn.To, Bodies))
|
||||
f = filepath.Join(root, SegmentFileName(sn.From, sn.To, Bodies))
|
||||
assertSegment(f)
|
||||
f = path.Join(root, SegmentFileName(sn.From, sn.To, Transactions))
|
||||
f = filepath.Join(root, SegmentFileName(sn.From, sn.To, Transactions))
|
||||
assertSegment(f)
|
||||
fmt.Printf("done:%s\n", f)
|
||||
}(sn)
|
||||
|
@ -2,7 +2,7 @@ package snapshotsync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/compress"
|
||||
@ -20,7 +20,7 @@ func TestOpenAllSnapshot(t *testing.T) {
|
||||
chainSnapshotCfg.ExpectBlocks = math.MaxUint64
|
||||
cfg := ethconfig.Snapshot{Enabled: true}
|
||||
createFile := func(from, to uint64, name SnapshotType) {
|
||||
c, err := compress.NewCompressor(context.Background(), "test", path.Join(dir, SegmentFileName(from, to, name)), dir, 100, 1)
|
||||
c, err := compress.NewCompressor(context.Background(), "test", filepath.Join(dir, SegmentFileName(from, to, name)), dir, 100, 1)
|
||||
require.NoError(err)
|
||||
defer c.Close()
|
||||
err = c.AddWord([]byte{1})
|
||||
@ -31,7 +31,7 @@ func TestOpenAllSnapshot(t *testing.T) {
|
||||
KeyCount: 1,
|
||||
BucketSize: 10,
|
||||
TmpDir: dir,
|
||||
IndexFile: path.Join(dir, IdxFileName(from, to, name)),
|
||||
IndexFile: filepath.Join(dir, IdxFileName(from, to, name)),
|
||||
LeafSize: 8,
|
||||
})
|
||||
require.NoError(err)
|
||||
|
Loading…
Reference in New Issue
Block a user