Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Oct 17, 2024
1 parent c1071e2 commit 1f962b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 6 additions & 9 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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() {
Expand Down
6 changes: 2 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1f962b1

Please sign in to comment.