Skip to content

Commit 46c850a

Browse files
authored
internal/ethapi: compact db missing key starts with 0xff (#28207)
Signed-off-by: jsvisa <[email protected]>
1 parent 37a2d91 commit 46c850a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/ethapi/api.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -2202,9 +2202,17 @@ func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
22022202
// ChaindbCompact flattens the entire key-value database into a single level,
22032203
// removing all unused slots and merging all keys.
22042204
func (api *DebugAPI) ChaindbCompact() error {
2205-
for b := byte(0); b < 255; b++ {
2206-
log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1))
2207-
if err := api.b.ChainDb().Compact([]byte{b}, []byte{b + 1}); err != nil {
2205+
cstart := time.Now()
2206+
for b := 0; b <= 255; b++ {
2207+
var (
2208+
start = []byte{byte(b)}
2209+
end = []byte{byte(b + 1)}
2210+
)
2211+
if b == 255 {
2212+
end = nil
2213+
}
2214+
log.Info("Compacting database", "range", fmt.Sprintf("%#X-%#X", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
2215+
if err := api.b.ChainDb().Compact(start, end); err != nil {
22082216
log.Error("Database compaction failed", "err", err)
22092217
return err
22102218
}

0 commit comments

Comments
 (0)