LevelDB: Seeked to start to get all the keys in HKEYS command.

This commit is contained in:
Sascha L. Teichmann 2014-08-11 15:13:18 +02:00
parent d321d1888b
commit d54af34288

View File

@ -158,13 +158,14 @@ func (ldbs *LevelDBSession) AllKeys(hash []byte) (keys chan []byte, n int, err e
ro.SetFillCache(false) ro.SetFillCache(false)
it := ldbs.backend.db.NewIterator(ro) it := ldbs.backend.db.NewIterator(ro)
it.SeekToFirst()
for ; it.Valid(); it.Next() { for ; it.Valid(); it.Next() {
n++ n++
} }
if err = it.GetError(); err != nil { if err = it.GetError(); err != nil {
ro.Close()
it.Close() it.Close()
ro.Close()
ldbs.backend.mutex.RUnlock() ldbs.backend.mutex.RUnlock()
return return
} }
@ -178,6 +179,7 @@ func (ldbs *LevelDBSession) AllKeys(hash []byte) (keys chan []byte, n int, err e
defer close(keys) defer close(keys)
it := ldbs.backend.db.NewIterator(ro) it := ldbs.backend.db.NewIterator(ro)
defer it.Close() defer it.Close()
it.SeekToFirst()
for ; it.Valid(); it.Next() { for ; it.Valid(); it.Next() {
keys <- it.Key() keys <- it.Key()
} }