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

refactor: change patch state parameters to be slices #80

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

itegulov
Copy link
Contributor

@itegulov itegulov commented Mar 1, 2022

In the end, I had to copy the slices into vectors anyway, not sure if there is a way to avoid that

@itegulov itegulov requested a review from ChaoticTempest March 1, 2022 23:30
Copy link
Member

@ChaoticTempest ChaoticTempest left a comment

Choose a reason for hiding this comment

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

Yeah that's the unfortunate part about these APIs. It's to keep them as convenient as possible for users to make use of, which means not having the most performant code underneath, which is fine in the context of workspaces

@ChaoticTempest ChaoticTempest merged commit a24945a into main Mar 2, 2022
@ChaoticTempest ChaoticTempest deleted the daniyar/patch-state-slice branch March 2, 2022 20:37
@adsick
Copy link

adsick commented Apr 18, 2022

Into<Vec<u8>> may work, I already try that:
path_state.rs:

    worker
        .patch_state(&contract_id, "STATE", status_msg.try_to_vec()?)
        .await?;

worker/impls.rs

    pub async fn patch_state(
        &self,
        contract_id: &AccountId,
        key: impl Into<Vec<u8>>,
        value: impl Into<Vec<u8>>,
    ) -> anyhow::Result<()> {
        self.workspace.patch_state(contract_id, key, value).await
    }

network/sandbox.rs

    pub(crate) async fn patch_state(
        &self,
        contract_id: &AccountId,
        key: impl Into<Vec<u8>>,
        value: impl Into<Vec<u8>>,
    ) -> anyhow::Result<()> {
        let state = StateRecord::Data {
            account_id: contract_id.to_owned(),
            data_key: key.into(),
            value: value.into(),
        };
...

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.

3 participants