Skip to content

Commit

Permalink
fix: Remove Iterator.Domain (#46)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #42 

## Description

Removes the Iterator.Domain function.
  • Loading branch information
AndrewSisley authored Jan 30, 2025
1 parent 89a74e7 commit cf3a95a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 37 deletions.
8 changes: 0 additions & 8 deletions badger/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ type rangeIterator struct {
closer func() error
}

func (it *rangeIterator) Domain() (start []byte, end []byte) {
return it.start, it.end
}

func (it *rangeIterator) Valid() bool {
if !it.i.Valid() {
return false
Expand Down Expand Up @@ -292,10 +288,6 @@ type prefixIterator struct {
closer func() error
}

func (it *prefixIterator) Domain() (start []byte, end []byte) {
return it.prefix, it.prefix
}

func (it *prefixIterator) Valid() bool {
return it.i.ValidForPrefix(it.prefix)
}
Expand Down
5 changes: 0 additions & 5 deletions kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ type Writer interface {
// Iterator is a read-only iterator that allows iteration over the underlying
// store (or a part of it).
type Iterator interface {
// The behaviour of Domain is undefined and varies heavily depending on
// which store implementation is being iterated over:
// https://github.com/sourcenetwork/corekv/issues/31
Domain() (start []byte, end []byte)

// Valid returns true if the iterator can return a valid item from
// `Value`.
//
Expand Down
4 changes: 0 additions & 4 deletions memory/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ func newRangeIter(db *Datastore, start, end []byte, reverse bool, version uint64
return iter
}

func (iter *iterator) Domain() (start []byte, end []byte) {
return iter.start, iter.end
}

func (iter *iterator) Valid() bool {
if !iter.hasItem {
return false
Expand Down
20 changes: 0 additions & 20 deletions namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ func prefixed(prefix, key []byte) []byte {
return append(cp(prefix), key...)
}

func strip(prefix, key []byte) []byte {
if len(key) >= len(prefix) {
return key[len(prefix):]
}
return key
}

// Iterator creates a new iterator instance
func (nstore *namespaceStore) Iterator(ctx context.Context, opts corekv.IterOptions) corekv.Iterator {
// make a copy of the namespace so that we can safely mutate it within this function
Expand Down Expand Up @@ -161,19 +154,6 @@ type namespaceIterator struct {
it corekv.Iterator
}

// todo: Should the domain contain the namespace, or strip it?
func (nIter *namespaceIterator) Domain() (start []byte, end []byte) {
start, end = nIter.it.Domain()
if start != nil {
start = strip(nIter.namespace, start)
}
if end != nil {
end = strip(nIter.namespace, end)
}

return start, end
}

func (nIter *namespaceIterator) Valid() bool {
if !nIter.it.Valid() {
return false
Expand Down

0 comments on commit cf3a95a

Please sign in to comment.