Browse Source

Merge pull request #62 from tendermint/tests-fix

fix goLevelDBIterator
pull/1842/head
Anton Kaliaev 7 years ago
committed by GitHub
parent
commit
8e5266a9ef
2 changed files with 15 additions and 4 deletions
  1. +15
    -3
      db/go_level_db.go
  2. +0
    -1
      db/mem_db.go

+ 15
- 3
db/go_level_db.go View File

@ -118,12 +118,12 @@ func (db *GoLevelDB) Stats() map[string]string {
}
type goLevelDBIterator struct {
iterator.Iterator
source iterator.Iterator
}
// Key returns a copy of the current key.
func (it *goLevelDBIterator) Key() []byte {
key := it.Key()
key := it.source.Key()
k := make([]byte, len(key))
copy(k, key)
@ -132,13 +132,25 @@ func (it *goLevelDBIterator) Key() []byte {
// Value returns a copy of the current value.
func (it *goLevelDBIterator) Value() []byte {
val := it.Value()
val := it.source.Value()
v := make([]byte, len(val))
copy(v, val)
return v
}
func (it *goLevelDBIterator) Error() error {
return it.source.Error()
}
func (it *goLevelDBIterator) Next() bool {
return it.source.Next()
}
func (it *goLevelDBIterator) Release() {
it.source.Release()
}
func (db *GoLevelDB) Iterator() Iterator {
return &goLevelDBIterator{db.db.NewIterator(nil, nil)}
}


+ 0
- 1
db/mem_db.go View File

@ -103,7 +103,6 @@ func (it *memDBIterator) Value() []byte {
func (it *memDBIterator) Release() {
it.db = nil
it.keys = nil
return
}
func (it *memDBIterator) Error() error {


Loading…
Cancel
Save