Skip to content

Commit

Permalink
internal/ethapi: compact db missing key starts with 0xff (#28207)
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <delweng@gmail.com>
  • Loading branch information
jsvisa committed Sep 28, 2023
1 parent 37a2d91 commit 46c850a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2202,9 +2202,17 @@ func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
// ChaindbCompact flattens the entire key-value database into a single level,
// removing all unused slots and merging all keys.
func (api *DebugAPI) ChaindbCompact() error {
for b := byte(0); b < 255; b++ {
log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1))
if err := api.b.ChainDb().Compact([]byte{b}, []byte{b + 1}); err != nil {
cstart := time.Now()
for b := 0; b <= 255; b++ {
var (
start = []byte{byte(b)}
end = []byte{byte(b + 1)}
)
if b == 255 {
end = nil
}
log.Info("Compacting database", "range", fmt.Sprintf("%#X-%#X", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
if err := api.b.ChainDb().Compact(start, end); err != nil {
log.Error("Database compaction failed", "err", err)
return err
}
Expand Down

0 comments on commit 46c850a

Please sign in to comment.