Skip to content

Commit 2fdba3a

Browse files
authored
Merge pull request #22294 from holiman/pruner_compact_fix
core/state/pruner: fix compaction range error
2 parents 944d901 + 74dbc20 commit 2fdba3a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

core/state/pruner/pruner.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,15 @@ func prune(maindb ethdb.Database, stateBloom *stateBloom, middleStateRoots map[c
186186
// Note for small pruning, the compaction is skipped.
187187
if count >= rangeCompactionThreshold {
188188
cstart := time.Now()
189-
190-
for b := byte(0); b < byte(16); b++ {
189+
for b := 0x00; b <= 0xf0; b += 0x10 {
191190
var (
192-
start = []byte{b << 4}
193-
end = []byte{(b+1)<<4 - 1}
191+
start = []byte{byte(b)}
192+
end = []byte{byte(b + 0x10)}
194193
)
195-
log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
196-
if b == 15 {
194+
if b == 0xf0 {
197195
end = nil
198196
}
197+
log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
199198
if err := maindb.Compact(start, end); err != nil {
200199
log.Error("Database compaction failed", "error", err)
201200
return err

0 commit comments

Comments
 (0)