-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update core store iterator API to return errors #14698
Comments
This should also be opened on cosmos-db. The interface is there. Should we do this as part of v1 on cosmos-db or v2? |
this is something we should keep in mind for store v2 but no need to change the current design. With things like orm and collections teams wont really need to deal with this api directly |
This issue has bitten me hard, I don't understand why it was closed. Cosmos iterators borrow the tendermint iterator interface, which according to the documentation are supposed to be used with the following pattern: var itr Iterator = ...
defer itr.Close()
for ; itr.Valid(); itr.Next() {
k, v := itr.Key(); itr.Value()
...
}
if err := itr.Error(); err != nil {
...
} However when you do so with most iterators returned by cosmos, With cosmos iterators there is currently no way to know if an iteration stopped because of an error or because it ran to completion. |
Yikes, that seems like a pretty bad design flaw :/ |
In #14622, we added error return values to the
cosmossdk.io/core/store.Store
methods. In discussions in that PR, it was noted that theIterator
interface doesn't have error return values but rather anError()
method which isn't used correctly. As a follow-up, we would like to adapt theIterator
interface to return errors in appropriate places.The text was updated successfully, but these errors were encountered: