Skip to content
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

fix: close iterators #792

Merged
merged 1 commit into from
Mar 25, 2022
Merged

fix: close iterators #792

merged 1 commit into from
Mar 25, 2022

Conversation

albertchon
Copy link
Contributor

Iterators should be closed after use.

I'd also potentially recommend renaming GetContractState(ctx sdk.Context, contractAddress sdk.AccAddress) sdk.Iterator to GetContractStateIterator(ctx sdk.Context, contractAddress sdk.AccAddress) sdk.Iterator so it's clear that clients should close the iterator themselves or simply change the function signature to take a callback so the usage pattern is standardized.

@albertchon albertchon requested a review from alpe as a code owner March 22, 2022 23:44
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #792 (1c9a1e1) into master (16ea5b0) will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #792      +/-   ##
==========================================
+ Coverage   58.64%   58.76%   +0.11%     
==========================================
  Files          50       50              
  Lines        5845     5857      +12     
==========================================
+ Hits         3428     3442      +14     
+ Misses       2166     2165       -1     
+ Partials      251      250       -1     
Impacted Files Coverage Δ
x/wasm/keeper/genesis.go 89.74% <100.00%> (+0.13%) ⬆️
x/wasm/keeper/keeper.go 88.09% <100.00%> (+0.54%) ⬆️
x/wasm/keeper/legacy_querier.go 70.52% <100.00%> (+0.63%) ⬆️

@alpe
Copy link
Contributor

alpe commented Mar 25, 2022

Thanks a lot for your contribution! 💪 . Good 👀 !
I agree with your proposal to modify GetContractState and standardize using callbacks. I will do a PR

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯

@alpe alpe merged commit 49ee92a into CosmWasm:master Mar 25, 2022
@albertchon albertchon deleted the b/close-iterators branch March 25, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants