mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-19 22:40:31 +00:00
core/rawdb: add DeleteRange to tableReplayer
This commit is contained in:
parent
777265620d
commit
cb06b56d7c
1 changed files with 12 additions and 0 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
package rawdb
|
package rawdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -272,6 +274,16 @@ func (r *tableReplayer) Delete(key []byte) error {
|
||||||
return r.w.Delete(trimmed)
|
return r.w.Delete(trimmed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteRange implements the interface KeyValueRangeDeleter.
|
||||||
|
func (r *tableReplayer) DeleteRange(start, end []byte) error {
|
||||||
|
trimmedStart := start[len(r.prefix):]
|
||||||
|
trimmedEnd := end[len(r.prefix):]
|
||||||
|
if rangeDeleter, ok := r.w.(ethdb.KeyValueRangeDeleter); ok {
|
||||||
|
return rangeDeleter.DeleteRange(trimmedStart, trimmedEnd)
|
||||||
|
}
|
||||||
|
return errors.New("ethdb.KeyValueWriter does not implement DeleteRange")
|
||||||
|
}
|
||||||
|
|
||||||
// Replay replays the batch contents.
|
// Replay replays the batch contents.
|
||||||
func (b *tableBatch) Replay(w ethdb.KeyValueWriter) error {
|
func (b *tableBatch) Replay(w ethdb.KeyValueWriter) error {
|
||||||
return b.batch.Replay(&tableReplayer{w: w, prefix: b.prefix})
|
return b.batch.Replay(&tableReplayer{w: w, prefix: b.prefix})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue