From 1f962b11e543d8f2b5a23a8057c119c01459d065 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Thu, 17 Oct 2024 15:57:55 +0700 Subject: [PATCH] save --- cmd/rpcdaemon/cli/config.go | 15 ++++++--------- eth/backend.go | 6 ++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 7efb31fff15..6726ed43565 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -406,14 +406,6 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger return nil, nil, nil, nil, nil, nil, nil, ff, nil, nil, errors.New("chain config not found in db. Need start erigon at least once on this db") } - allSegmentsDownloadComplete, err := downloaderrawdb.AllSegmentsDownloadCompleteFlag(cfg.Dirs) - if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err - } - if !allSegmentsDownloadComplete { - log.Warn("[rpc] download of segments not complete yet (need wait, then RPC will work)") - } - // Configure sapshots allSnapshots = freezeblocks.NewRoSnapshots(cfg.Snap, cfg.Dirs.Snap, 0, logger) allBorSnapshots = freezeblocks.NewBorRoSnapshots(cfg.Snap, cfg.Dirs.Snap, 0, logger) @@ -424,9 +416,12 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger if err != nil { return nil, nil, nil, nil, nil, nil, nil, ff, nil, nil, fmt.Errorf("create aggregator: %w", err) } - // To povide good UX - immediatly can read snapshots after RPCDaemon start, even if Erigon is down // Erigon does store list of snapshots in db: means RPCDaemon can read this list now, but read by `remoteKvClient.Snapshots` after establish grpc connection + allSegmentsDownloadComplete, err := downloaderrawdb.AllSegmentsDownloadCompleteFlag(cfg.Dirs) + if err != nil { + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + } if allSegmentsDownloadComplete { allSnapshots.OptimisticalyReopenFolder() allBorSnapshots.OptimisticalyReopenFolder() @@ -444,6 +439,8 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger }) return nil }) + } else { + log.Warn("[rpc] download of segments not complete yet (need wait, then RPC will work)") } onNewSnapshot = func() { diff --git a/eth/backend.go b/eth/backend.go index 6ef6356812d..dfefb12794e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -1448,16 +1448,14 @@ func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConf if err != nil { return nil, nil, nil, nil, nil, err } - if !allSegmentsDownloadComplete { - log.Warn("[rpc] download of segments not complete yet (need wait, then RPC will work)") - } - if allSegmentsDownloadComplete { allSnapshots.OptimisticalyReopenFolder() if isBor { allBorSnapshots.OptimisticalyReopenFolder() } _ = agg.OpenFolder() + } else { + log.Warn("[rpc] download of segments not complete yet (need wait, then RPC will work)") } blockWriter := blockio.NewBlockWriter()