Skip to content

State store custom usage pattern enhancements #730

Open
@gnunicorn

Description

@gnunicorn

Our StateStore implementation have a very rough and rudimentary custom API to allow developers using the API to save data with it. However that is very low level and pretty limited for broader patterns - you can only get and set custom key-value pairs:

/// Get arbitrary data from the custom store
///
/// # Arguments
///
/// * `key` - The key to fetch data for
async fn get_custom_value(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
/// Put arbitrary data into the custom store
///
/// # Arguments
///
/// * `key` - The key to insert data into
///
/// * `value` - The value to insert
async fn set_custom_value(&self, key: &[u8], value: Vec<u8>) -> Result<Option<Vec<u8>>>;

While a common pattern that we've worked out with our stores is to provide lists of keys- and values that are prefixed in a certain way. With these implementations using (if activated) encryption internally, this isn't really possible, nor is it possible to iterate over an unknown list of prefixed keys, limiting the usefulness of the store.

Aside from providing some handy methods allowing you to use Serialize + Deserialize for keys + values and have the store figure out the details, I propose we also add [get|set]_prefixed_custom_value functions that allow to specify an array of prefixes in front of the key to allow the prefix-pattern (with encrypted data) we've been grown accustomed to also to be used by developers building on top of our SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedInterested in working on the project? These are great additions we'd like to have!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions