From e5081c78b9082ab38a0e927a2e695e74bb3116e7 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 9 Feb 2022 09:28:06 +0700 Subject: [PATCH] bor: ensure db exists (#3449) --- cmd/rpcdaemon/cli/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 3b7b7a418..1577a48bf 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -260,6 +260,14 @@ 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") + { + // ensure db exist + tmpDb, err := kv2.NewMDBX(logger).Path(borDbPath).Open() + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, err + } + tmpDb.Close() + } log.Trace("Creating consensus db", "path", borDbPath) borKv, err = kv2.NewMDBX(logger).Path(borDbPath).Readonly().Open() if err != nil {