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

storage extension #226

Closed
cymqqqq opened this issue Jun 23, 2024 · 0 comments
Closed

storage extension #226

cymqqqq opened this issue Jun 23, 2024 · 0 comments

Comments

@cymqqqq
Copy link
Contributor

cymqqqq commented Jun 23, 2024

Background: there are strict_serialize_to_file and to_strict_serialized methods in the strict_type, at the 0.11-beta.6 now, we have an fs module to store index, state, and stash data into a local dat format file. (strict_serialize_to_file is used here)

But if people want to store the bytes data in their KV database but not the file, such that I want to set the key as the contract id, and the value as the schema bytes data. Then I can use the to_strict_serialized method to serialize the schema into bytes, then store it in my local leveldb or other KV database.

And when I want to construct the stock runtime, then I can first load the bytes data from the KV database, then use the from_strict_serialized method to deserialize the bytes into the index, stash, and state struct. (Finally, I can build a stock runtime with them).

So I want to ask if there are any possibilities for us to add to_strict_serialized, and from_strict_serialized into a new storage module(like fs), then we can add new store_bytes, and load_bytes traits into stash, state, and index provider. Such as:
impl StoreBytes for MemState { fn store_bytes(&self, bytes_data: Vec<u8>) -> Result<(), SerializeError> { self.to_strict_serialized::<U32>(bytes_data); } }

impl LoadBytes for MemState { fn load_bytes(bytes_data: Vec<u8>) -> Result<Self, DeserializeError> { Self::from_strict_serialized::<U32>(bytes_data) } }

@cymqqqq cymqqqq closed this as completed Jul 12, 2024
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

No branches or pull requests

1 participant