From 7da125879bfa646184e2c39a323ce029afd5e9b2 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Fri, 24 Mar 2023 15:50:00 +0700 Subject: [PATCH] better context --- state/history.go | 4 ---- state/inverted_index.go | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/state/history.go b/state/history.go index 0b12bfb78..60ef3440c 100644 --- a/state/history.go +++ b/state/history.go @@ -1093,8 +1093,6 @@ func (h *History) prune(ctx context.Context, txFrom, txTo, limit uint64, logEver } select { - case <-ctx.Done(): - return nil case <-logEvery.C: log.Info("[snapshots] prune history", "name", h.filenameBase, "to_step", fmt.Sprintf("%.2f", float64(txTo)/float64(h.aggregationStep)), "prefix", fmt.Sprintf("%x", key[:8])) default: @@ -1128,8 +1126,6 @@ func (h *History) prune(ctx context.Context, txFrom, txTo, limit uint64, logEver } select { - case <-ctx.Done(): - return nil case <-logEvery.C: log.Info("[snapshots] prune history", "name", h.filenameBase, "to_step", fmt.Sprintf("%.2f", float64(txTo)/float64(h.aggregationStep)), "prefix", fmt.Sprintf("%x", key[:8])) default: diff --git a/state/inverted_index.go b/state/inverted_index.go index a6328cb20..9620d53f1 100644 --- a/state/inverted_index.go +++ b/state/inverted_index.go @@ -1137,8 +1137,7 @@ func (ii *InvertedIndex) collate(ctx context.Context, txFrom, txTo uint64, roTx log.Debug("[snapshots] collate history", "name", ii.filenameBase, "range", fmt.Sprintf("%.2f-%.2f", float64(txNum)/float64(ii.aggregationStep), float64(txTo)/float64(ii.aggregationStep))) bitmap.RunOptimize() case <-ctx.Done(): - err := ctx.Err() - return nil, err + return nil, ctx.Err() default: } } @@ -1334,7 +1333,7 @@ func (ii *InvertedIndex) prune(ctx context.Context, txFrom, txTo, limit uint64, } select { case <-ctx.Done(): - return nil + return ctx.Err() default: } } @@ -1356,8 +1355,6 @@ func (ii *InvertedIndex) prune(ctx context.Context, txFrom, txTo, limit uint64, } select { - case <-ctx.Done(): - return nil case <-logEvery.C: log.Info("[snapshots] prune history", "name", ii.filenameBase, "to_step", fmt.Sprintf("%.2f", float64(txTo)/float64(ii.aggregationStep)), "prefix", fmt.Sprintf("%x", key[:8])) default: