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

[x/programs] Change the state's put and delete methods to handle batches on the host #868

Open
richardpringle opened this issue Apr 26, 2024 · 0 comments

Comments

@richardpringle
Copy link
Contributor

Where we can, we should avoid going in and out of the wasm-context. There should always be the option to batch calls.

Further, I think a single method for updates and deletes would be beneficial. Ideally, we could use something like

#[derive(BorshSerialize)]
struct CacheEntry<K> {
    key: K, 
    value: CacheValue,
}

#[derive(BorshSerialize)]
enum CacheValue {
    Get(Vec<u8>),
    Update(Vec<u8>),
    Delete,
}

I also think we would further benefit from

[derive(BorshSerialize)]
enum Update<K> {
    Put(K, Box<dyn BorshSerialize>),
    Delete(K),
}

where we could defer the actual serialization. It might be trickier to downcast the Box<dyn BorshSerialize> to a Box<T> when fetching from the cache though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog 🗄️
Development

No branches or pull requests

1 participant