erigon22: auto create dir (#4911)

This commit is contained in:
Alex Sharov 2022-08-03 14:43:47 +07:00 committed by GitHub
parent db0c4e9d41
commit 0d21da4a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ import (
"time" "time"
libcommon "github.com/ledgerwatch/erigon-lib/common" libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/common/dir"
"github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv"
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx" kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
libstate "github.com/ledgerwatch/erigon-lib/state" libstate "github.com/ledgerwatch/erigon-lib/state"
@ -312,6 +313,7 @@ func Erigon22(genesis *core.Genesis, logger log.Logger) error {
return err return err
} }
} }
dir.MustExist(reconDbPath)
limiter := semaphore.NewWeighted(int64(runtime.NumCPU() + 1)) limiter := semaphore.NewWeighted(int64(runtime.NumCPU() + 1))
db, err := kv2.NewMDBX(logger).Path(reconDbPath).RoTxsLimiter(limiter).Open() db, err := kv2.NewMDBX(logger).Path(reconDbPath).RoTxsLimiter(limiter).Open()
if err != nil { if err != nil {
@ -401,10 +403,8 @@ func Erigon22(genesis *core.Genesis, logger log.Logger) error {
} else if err = os.RemoveAll(aggDir); err != nil { } else if err = os.RemoveAll(aggDir); err != nil {
return err return err
} }
if err = os.MkdirAll(aggDir, 0755); err != nil {
return err
}
} }
dir.MustExist(reconDbPath)
agg, err := libstate.NewAggregator22(aggDir, AggregationStep) agg, err := libstate.NewAggregator22(aggDir, AggregationStep)
if err != nil { if err != nil {
return err return err