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

Pass Reference of External Call Context #1141

Merged
merged 7 commits into from
Jul 15, 2024
Merged

Pass Reference of External Call Context #1141

merged 7 commits into from
Jul 15, 2024

Conversation

samliok
Copy link
Contributor

@samliok samliok commented Jul 15, 2024

Forces ExternalCallContext to be passed by reference. This allows programs to reuse the same context without having to create a new one for each external call.

@iFrostizz
Copy link
Contributor

I'm just wondering if it would make sense to also borrow the fields inside of the ExternalCallContext, for instance you cannot do:

#[public]
pub fn inc(_: Context, external: Program, address: Address) {
    let ctx = ExternalCallContext::new(external, 1_000_000, 0);
    counter::inc(&ctx, address, 1);
    let ctx = ExternalCallContext::new(external, 1_000_000, 0);
    counter::inc(&ctx, address, 1);
}

because external is moved since Program doesn't implement Copy nor we (probably) want

@samliok samliok self-assigned this Jul 15, 2024
iFrostizz
iFrostizz previously approved these changes Jul 15, 2024
@samliok samliok merged commit 9bda4d7 into main Jul 15, 2024
20 checks passed
@samliok samliok deleted the extern_context branch July 15, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants