Skip to content

Commit

Permalink
go tendermint badger: don't scan whole keyspace
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Feb 11, 2020
1 parent 0c4e3ea commit 6b06653
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions go/consensus/tendermint/db/badger/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,23 @@ func (it *badgerDBIterator) Next() {
panic("Next with invalid iterator")
}

for {
it.iter.Next()
if !it.iter.Valid() {
break
}

item := it.iter.Item()
k := fromDBKeyNoCopy(item.KeyCopy(nil))
if dbm.IsKeyInDomain(k, it.start, it.end) {
it.current.item = item
it.current.key = k
it.current.value = nil // Copy done on access.
return
}
it.iter.Next()
if !it.iter.Valid() {
it.Close()
return
}

it.Close()
item := it.iter.Item()
k := fromDBKeyNoCopy(item.KeyCopy(nil))
if dbm.IsKeyInDomain(k, it.start, it.end) {
it.current.item = item
it.current.key = k
it.current.value = nil // Copy done on access.
return
} else {
it.Close()
return
}
}

func (it *badgerDBIterator) Key() []byte {
Expand Down

0 comments on commit 6b06653

Please sign in to comment.