mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
ethdb: moved DeleteRange from KeyValueWriter to RangeDeleter
This commit is contained in:
parent
f596f79f61
commit
c1f1ade52e
13 changed files with 14 additions and 62 deletions
|
|
@ -217,11 +217,6 @@ func (b *tableBatch) Delete(key []byte) error {
|
|||
return b.batch.Delete(append([]byte(b.prefix), key...))
|
||||
}
|
||||
|
||||
// DeleteRange implements KeyValueWriter (not supported on batches).
|
||||
func (b *tableBatch) DeleteRange(start, end []byte) error {
|
||||
panic("DeleteRange is not supported on batches")
|
||||
}
|
||||
|
||||
// ValueSize retrieves the amount of data queued up for writing.
|
||||
func (b *tableBatch) ValueSize() int {
|
||||
return b.batch.ValueSize()
|
||||
|
|
@ -256,12 +251,6 @@ func (r *tableReplayer) Delete(key []byte) error {
|
|||
return r.w.Delete(trimmed)
|
||||
}
|
||||
|
||||
// DeleteRange implements the interface KeyValueWriter.
|
||||
func (r *tableReplayer) DeleteRange(start, end []byte) error {
|
||||
trimmedStart, trimmedEnd := start[len(r.prefix):], end[len(r.prefix):]
|
||||
return r.w.DeleteRange(trimmedStart, trimmedEnd)
|
||||
}
|
||||
|
||||
// Replay replays the batch contents.
|
||||
func (b *tableBatch) Replay(w ethdb.KeyValueWriter) error {
|
||||
return b.batch.Replay(&tableReplayer{w: w, prefix: b.prefix})
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ func (r *testReplayer) Delete(key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *testReplayer) DeleteRange(start, end []byte) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func testTableDatabase(t *testing.T, prefix string) {
|
||||
db := NewTable(NewMemoryDatabase(), prefix)
|
||||
|
||||
|
|
|
|||
|
|
@ -116,8 +116,6 @@ func (bloom *stateBloom) Put(key []byte, value []byte) error {
|
|||
// Delete removes the key from the key-value data store.
|
||||
func (bloom *stateBloom) Delete(key []byte) error { panic("not supported") }
|
||||
|
||||
func (bloom *stateBloom) DeleteRange(start, end []byte) error { panic("not supported") }
|
||||
|
||||
// Contain is the wrapper of the underlying contains function which
|
||||
// reports whether the key is contained.
|
||||
// - If it says yes, the key may be contained
|
||||
|
|
|
|||
|
|
@ -97,10 +97,6 @@ func (r *replayer) Delete(key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *replayer) DeleteRange(start, end []byte) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func byteToHex(str []byte) []byte {
|
||||
l := len(str) * 2
|
||||
var nibbles = make([]byte, l)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ type KeyValueWriter interface {
|
|||
|
||||
// Delete removes the key from the key-value data store.
|
||||
Delete(key []byte) error
|
||||
}
|
||||
|
||||
// RangeDeleter wraps the DeleteRange method of a backing data store.
|
||||
type RangeDeleter interface {
|
||||
// DeleteRange deletes all of the keys (and values) in the range [start,end)
|
||||
// (inclusive on start, exclusive on end).
|
||||
DeleteRange(start, end []byte) error
|
||||
|
|
@ -65,6 +68,7 @@ type KeyValueStore interface {
|
|||
KeyValueReader
|
||||
KeyValueWriter
|
||||
KeyValueStater
|
||||
RangeDeleter
|
||||
Batcher
|
||||
Iteratee
|
||||
Compacter
|
||||
|
|
@ -193,6 +197,7 @@ type ResettableAncientStore interface {
|
|||
type Database interface {
|
||||
Reader
|
||||
Writer
|
||||
RangeDeleter
|
||||
Batcher
|
||||
Iteratee
|
||||
Stater
|
||||
|
|
|
|||
|
|
@ -441,11 +441,6 @@ func (b *batch) Delete(key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteRange implements KeyValueWriter (not supported on batches).
|
||||
func (b *batch) DeleteRange(start, end []byte) error {
|
||||
panic("DeleteRange is not supported on batches")
|
||||
}
|
||||
|
||||
// ValueSize retrieves the amount of data queued up for writing.
|
||||
func (b *batch) ValueSize() int {
|
||||
return b.size
|
||||
|
|
|
|||
|
|
@ -229,11 +229,6 @@ func (b *batch) Delete(key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteRange implements KeyValueWriter (not supported on batches).
|
||||
func (b *batch) DeleteRange(start, end []byte) error {
|
||||
panic("DeleteRange is not supported on batches")
|
||||
}
|
||||
|
||||
// ValueSize retrieves the amount of data queued up for writing.
|
||||
func (b *batch) ValueSize() int {
|
||||
return b.size
|
||||
|
|
|
|||
|
|
@ -550,11 +550,6 @@ func (b *batch) Delete(key []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteRange implements KeyValueWriter (not supported on batches).
|
||||
func (b *batch) DeleteRange(start, end []byte) error {
|
||||
panic("DeleteRange is not supported on batches")
|
||||
}
|
||||
|
||||
// ValueSize retrieves the amount of data queued up for writing.
|
||||
func (b *batch) ValueSize() int {
|
||||
return b.size
|
||||
|
|
|
|||
|
|
@ -704,10 +704,6 @@ func (n *proofList) Delete(key []byte) error {
|
|||
panic("not supported")
|
||||
}
|
||||
|
||||
func (n *proofList) DeleteRange(start, end []byte) error {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
// GetProof returns the Merkle-proof for a given account and optionally some storage keys.
|
||||
func (api *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error) {
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -918,10 +918,6 @@ func (w *hookWriter) Delete(key []byte) error {
|
|||
return w.db.Delete(key)
|
||||
}
|
||||
|
||||
func (w *hookWriter) DeleteRange(start, end []byte) error {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
func testSyncAbort(t *testing.T, scheme string) {
|
||||
var (
|
||||
srcDisk = rawdb.NewMemoryDatabase()
|
||||
|
|
|
|||
|
|
@ -868,7 +868,6 @@ func (b *spongeBatch) Put(key, value []byte) error {
|
|||
return nil
|
||||
}
|
||||
func (b *spongeBatch) Delete(key []byte) error { panic("implement me") }
|
||||
func (b *spongeBatch) DeleteRange(start, end []byte) error { panic("implement me") }
|
||||
func (b *spongeBatch) ValueSize() int { return 100 }
|
||||
func (b *spongeBatch) Write() error { return nil }
|
||||
func (b *spongeBatch) Reset() {}
|
||||
|
|
|
|||
|
|
@ -156,10 +156,6 @@ func (n *ProofList) Delete(key []byte) error {
|
|||
panic("not supported")
|
||||
}
|
||||
|
||||
func (n *ProofList) DeleteRange(start, end []byte) error {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
// DataSize returns the aggregated data size of nodes in the list
|
||||
func (n ProofList) DataSize() int {
|
||||
var size int
|
||||
|
|
|
|||
|
|
@ -532,10 +532,6 @@ func (c *cleaner) Delete(key []byte) error {
|
|||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (c *cleaner) DeleteRange(start, end []byte) error {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
// Initialized returns an indicator if state data is already initialized
|
||||
// in hash-based scheme by checking the presence of genesis state.
|
||||
func (db *Database) Initialized(genesisRoot common.Hash) bool {
|
||||
|
|
|
|||
Loading…
Reference in a new issue