forked from cerc-io/plugeth
internal/ethapi: compact db missing key starts with 0xff (#28207)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
37a2d919b0
commit
46c850a941
@ -2202,9 +2202,17 @@ func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
|
|||||||
// ChaindbCompact flattens the entire key-value database into a single level,
|
// ChaindbCompact flattens the entire key-value database into a single level,
|
||||||
// removing all unused slots and merging all keys.
|
// removing all unused slots and merging all keys.
|
||||||
func (api *DebugAPI) ChaindbCompact() error {
|
func (api *DebugAPI) ChaindbCompact() error {
|
||||||
for b := byte(0); b < 255; b++ {
|
cstart := time.Now()
|
||||||
log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1))
|
for b := 0; b <= 255; b++ {
|
||||||
if err := api.b.ChainDb().Compact([]byte{b}, []byte{b + 1}); err != nil {
|
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)
|
log.Error("Database compaction failed", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user