From 74dbc20260caac0159ca59bfad1f41321130e676 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 8 Feb 2021 20:31:52 +0100 Subject: [PATCH] core/state/pruner: fix compaction range error --- core/state/pruner/pruner.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/state/pruner/pruner.go b/core/state/pruner/pruner.go index 84a8952b57..1fbfa55b6a 100644 --- a/core/state/pruner/pruner.go +++ b/core/state/pruner/pruner.go @@ -186,16 +186,15 @@ func prune(maindb ethdb.Database, stateBloom *stateBloom, middleStateRoots map[c // Note for small pruning, the compaction is skipped. if count >= rangeCompactionThreshold { cstart := time.Now() - - for b := byte(0); b < byte(16); b++ { + for b := 0x00; b <= 0xf0; b += 0x10 { var ( - start = []byte{b << 4} - end = []byte{(b+1)<<4 - 1} + start = []byte{byte(b)} + end = []byte{byte(b + 0x10)} ) - log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart))) - if b == 15 { + if b == 0xf0 { end = nil } + log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart))) if err := maindb.Compact(start, end); err != nil { log.Error("Database compaction failed", "error", err) return err