Skip to content

Commit

Permalink
cleveldb: fix handling of empty keys as iterator endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Mar 10, 2020
1 parent 7204cbb commit 8e1f9b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

- [boltdb] Properly handle blank keys in iterators

- [cleveldb] Fix handling of empty keys as iterator endpoints

- [goleveldb] [\#58](https://github.com/tendermint/tm-db/pull/58) Make `Batch.Close()` actually remove the batch contents

## 0.4.1
Expand Down
4 changes: 2 additions & 2 deletions cleveldb_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ Iterator = (*cLevelDBIterator)(nil)

func newCLevelDBIterator(source *levigo.Iterator, start, end []byte, isReverse bool) *cLevelDBIterator {
if isReverse {
if end == nil {
if end == nil || len(end) == 0 {
source.SeekToLast()
} else {
source.Seek(end)
Expand All @@ -34,7 +34,7 @@ func newCLevelDBIterator(source *levigo.Iterator, start, end []byte, isReverse b
}
}
} else {
if start == nil {
if start == nil || len(start) == 0 {
source.SeekToFirst()
} else {
source.Seek(start)
Expand Down

0 comments on commit 8e1f9b7

Please sign in to comment.