Unverified Commit 81662fe8 authored by Evolution404's avatar Evolution404 Committed by GitHub

core/rawdb: handle prefix in table.compact method (#22911)

parent a6c46278
...@@ -131,6 +131,8 @@ func (t *table) Compact(start []byte, limit []byte) error { ...@@ -131,6 +131,8 @@ func (t *table) Compact(start []byte, limit []byte) error {
// If no start was specified, use the table prefix as the first value // If no start was specified, use the table prefix as the first value
if start == nil { if start == nil {
start = []byte(t.prefix) start = []byte(t.prefix)
} else {
start = append([]byte(t.prefix), start...)
} }
// If no limit was specified, use the first element not matching the prefix // If no limit was specified, use the first element not matching the prefix
// as the limit // as the limit
...@@ -147,6 +149,8 @@ func (t *table) Compact(start []byte, limit []byte) error { ...@@ -147,6 +149,8 @@ func (t *table) Compact(start []byte, limit []byte) error {
limit = nil limit = nil
} }
} }
} else {
limit = append([]byte(t.prefix), limit...)
} }
// Range correctly calculated based on table prefix, delegate down // Range correctly calculated based on table prefix, delegate down
return t.db.Compact(start, limit) return t.db.Compact(start, limit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment