From d14b894f07679612502aaf306062f0a2ad56303b Mon Sep 17 00:00:00 2001 From: Enrique Avila Asapche <eavilaasapche@gmail.com> Date: Fri, 10 Sep 2021 15:59:22 +0300 Subject: [PATCH] deleted kv.log section and instead call it in cfg.prune.Receipts.Enabled --- eth/stagedsync/stage_execute.go | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/eth/stagedsync/stage_execute.go b/eth/stagedsync/stage_execute.go index 077d64ba0f..21c9342684 100644 --- a/eth/stagedsync/stage_execute.go +++ b/eth/stagedsync/stage_execute.go @@ -615,6 +615,9 @@ func PruneExecutionStage(s *PruneState, tx kv.RwTx, cfg ExecuteBlockCfg, ctx con if err = pruneReceipts(tx, kv.Receipts, logPrefix, cfg.prune.Receipts.PruneTo(s.ForwardProgress), logEvery, ctx); err != nil { return err } + if err = pruneReceipts(tx, kv.Log, logPrefix, cfg.prune.Receipts.PruneTo(s.ForwardProgress),logEvery, ctx); err != nil{ + return err + } } if cfg.prune.CallTraces.Enabled() { if err = pruneCallTracesSet(tx, logPrefix, cfg.prune.CallTraces.PruneTo(s.ForwardProgress), logEvery, ctx); err != nil { @@ -635,7 +638,6 @@ func PruneExecutionStage(s *PruneState, tx kv.RwTx, cfg ExecuteBlockCfg, ctx con func pruneReceipts(tx kv.RwTx, table string, logPrefix string, pruneTo uint64, logEvery *time.Ticker, ctx context.Context) error { c, err := tx.RwCursor(table) - fmt.Println(kv.Receipts) if err != nil { return fmt.Errorf("failed to create cursor for pruning %w", err) @@ -662,32 +664,6 @@ func pruneReceipts(tx kv.RwTx, table string, logPrefix string, pruneTo uint64, l return fmt.Errorf("failed to remove for block %d: %w", blockNum, err) } } - - c, err = tx.RwCursor(kv.Log) - if err != nil { - return fmt.Errorf("failed to create cursor for pruning %w", err) - } - defer c.Close() - - for k, _, err := c.First(); k != nil; k, _, err = c.Next() { - if err != nil { - return err - } - blockNum := binary.BigEndian.Uint64(k) - if blockNum >= pruneTo { - break - } - select { - case <-logEvery.C: - log.Info(fmt.Sprintf("[%s]", logPrefix), "table", kv.Log, "block", blockNum) - case <-ctx.Done(): - return common.ErrStopped - default: - } - if err = c.DeleteCurrent(); err != nil { - return fmt.Errorf("failed to remove for block %d: %w", blockNum, err) - } - } return nil } -- GitLab