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

Adding global context secp256k1 #45

Merged
merged 2 commits into from
Aug 2, 2019

Conversation

elichai
Copy link
Contributor

@elichai elichai commented Jul 23, 2019

This resolves #44

Before this for every multiplication you created the context. which is a very hungry operation (cpu, memory etc).

Instead we're creating a context only once and keep using that.
this context is thread safe. you can pass it around however you want.
the only constraint are:

There is no promise about the exact memory size and representation, meaning that you cannot save it to disk and reload later.
no one should try and modify it's memory(not a problem in rust)

@omershlo omershlo requested a review from gbenattar July 23, 2019 20:31
@omershlo
Copy link
Contributor

@elichai Is the serde_json necessary? what is his purpose?
@gbenattar can I merge?

@elichai
Copy link
Contributor Author

elichai commented Jul 23, 2019

It's used in the tests so I moved it from the dependencies to the dev-dependencies

@omershlo
Copy link
Contributor

got it, thanks.
@gbenattar waiting for your ok

CONTEXT = Some(Secp256k1::verification_only());
});
unsafe { CONTEXT.as_ref().unwrap() }
}
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I have. that's basically what's lazy_static is doing and this doesn't require a new dependency

@gbenattar
Copy link
Contributor

I am approving this PR given the following pre-condition:

@omershlo omershlo merged commit 98d6e1d into ZenGo-X:master Aug 2, 2019
@elichai elichai deleted the 2019-07-secp-global-context branch May 19, 2020 10:53
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.

4 participants