bor snaps: "erigon snapshots retire" to build bor files (#8912)

This commit is contained in:
Alex Sharov 2023-12-06 19:12:43 +07:00 committed by GitHub
parent c477281362
commit 754276909b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -470,12 +470,15 @@ func doRetireCommand(cliCtx *cli.Context) error {
if err := br.RetireBlocks(ctx, i, i+every, log.LvlInfo, nil, nil); err != nil {
panic(err)
}
if err := br.RetireBorBlocks(ctx, i, i+every, log.LvlInfo, nil, nil); err != nil {
panic(err)
}
if err := db.Update(ctx, func(tx kv.RwTx) error {
if err := rawdb.WriteSnapshots(tx, blockReader.FrozenFiles(), agg.Files()); err != nil {
return err
}
for j := 0; j < 10_000; j++ { // prune happens by small steps, so need many runs
if err := br.PruneAncientBlocks(tx, 100, false /* includeBor */); err != nil {
if err := br.PruneAncientBlocks(tx, 100, true /* includeBor */); err != nil {
return err
}
}

View File

@ -1352,7 +1352,7 @@ func (br *BlockRetire) RetireBlocksInBackground(ctx context.Context, forwardProg
if includeBor {
blockFrom, blockTo, ok = CanRetire(forwardProgress, br.blockReader.FrozenBorBlocks())
if ok {
if err := br.RetireBorBlocks(ctx, blockFrom, blockTo, lvl, seedNewSnapshots); err != nil {
if err := br.RetireBorBlocks(ctx, blockFrom, blockTo, lvl, seedNewSnapshots, onDeleteSnapshots); err != nil {
br.logger.Warn("[bor snapshots] retire blocks", "err", err, "fromBlock", blockFrom, "toBlock", blockTo)
}
}

View File

@ -174,7 +174,7 @@ type borSpanSegments struct {
segments []*BorSpanSegment
}
func (br *BlockRetire) RetireBorBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl, seedNewSnapshots func(downloadRequest []services.DownloadRequest) error) error {
func (br *BlockRetire) RetireBorBlocks(ctx context.Context, blockFrom, blockTo uint64, lvl log.Lvl, seedNewSnapshots func(downloadRequest []services.DownloadRequest) error, onDelete func(l []string) error) error {
chainConfig := fromdb.ChainConfig(br.db)
notifier, logger, blockReader, tmpDir, db, workers := br.notifier, br.logger, br.blockReader, br.tmpDir, br.db, br.workers
logger.Log(lvl, "[bor snapshots] Retire Bor Blocks", "range", fmt.Sprintf("%dk-%dk", blockFrom/1000, blockTo/1000))
@ -211,10 +211,6 @@ func (br *BlockRetire) RetireBorBlocks(ctx context.Context, blockFrom, blockTo u
}
return nil
}
onDelete := func(files []string) error {
//TODO: add Downloader API to delete files
return nil
}
err := merger.Merge(ctx, snapshots, rangesToMerge, snapshots.Dir(), true /* doIndex */, onMerge, onDelete)
if err != nil {
return err