Skip to content

feat(storage): implement iteration support #1714

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

Closed
wants to merge 3 commits into from

Conversation

tmpolaczyk
Copy link
Contributor

This PR adds a prefix_iterator to the Storage trait, which allows iterating over all the storage keys that start with the same prefix.

This can be used to implement storage migrations by iterating over all the existing keys and updating them to the new format. Also it can be used to check if the storage is empty, or assert that there are no keys with some specific prefix. In this PR it is not used anywhere.

TODO: add tests

let hash_key = calculate_sha256(key);
self.backend.delete(hash_key.as_ref())
}

fn prefix_iterator<'a, 'b: 'a>(&'a self, _prefix: &'b [u8]) -> Result<StorageIterator<'a>> {
bail!("Iteration is not supported when using encrypted storage")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a problem: it looks like there is a hidden feature that allows to use an encrypted storage for the node. I would try to deprecate that in some way to avoid future problems. Otherwise, we must always assume that iteration can fail.

@tmpolaczyk
Copy link
Contributor Author

This was already merged as part of #2159

@tmpolaczyk tmpolaczyk closed this Apr 6, 2022
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.

1 participant