Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Extend Externalities with for_keys_with_prefix instead of just clear_prefix #3883

@gui1117

Description

@gui1117

Currently Externalities only provides way to clear_prefix and clear_child_prefix which allows to clear all keys with prefix in main trie or a child trie.

In order to do so the current backend does iterate over keys with such prefix and removes them. It would be great to expose a function for_keys_with_prefix(prefix, callback) which would allow to iterate on all keys with prefix in main trie and in child tries.

The main interest is for childtrie, if you could isolate some storage into its child trie you could then iterate on all values in this child trie which can be usefull

Cons

  • the function fn for_keys_with_prefix(prefix, callback) would need to pass a callback from wasm to native. Which might be unsuitable.
    the wasm callback will have to be executed on each value found.
    as the only intereset for me is to iterate on all value of a childtrie maybe the solution is actually to have a new externality which is fn all_value which returns all values in vec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    J0-enhancementAn additional feature request.Z7-questionIssue is a question. Closer should answer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions