diff --git a/database/ffldb/ldb/cursor.go b/database/ffldb/ldb/cursor.go index 43118a8c0..d1ea0248f 100644 --- a/database/ffldb/ldb/cursor.go +++ b/database/ffldb/ldb/cursor.go @@ -53,18 +53,20 @@ func (c *LevelDBCursor) Seek(key []byte) error { return errors.New("cannot seek a closed cursor") } + notFoundErr := errors.Wrapf(database.ErrNotFound, "key %s not "+ + "found", hex.EncodeToString(key)) found := c.ldbIterator.Seek(key) if !found { - return errors.Wrapf(database.ErrNotFound, "key %s not "+ - "found", hex.EncodeToString(key)) + return notFoundErr } - currentKey, err := c.Key() - if err != nil { - return err + + // Use c.ldbIterator.Key because c.Key removes the prefix from the key + currentKey := c.ldbIterator.Key() + if currentKey == nil { + return notFoundErr } if !bytes.Equal(currentKey, key) { - return errors.Wrapf(database.ErrNotFound, "key %s not "+ - "found", hex.EncodeToString(key)) + return notFoundErr } return nil