-
-
Notifications
You must be signed in to change notification settings - Fork 475
Complicate entropy rng #508
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
Conversation
d5c9257
to
c9d35fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, those cfg
s are horrible. Can we simplify them to cfg(any(feature="std", feature="stdweb"))
?
I've thought about enabling stdweb
by default, but it doesn't affect that cfg
. We could make std
imply stdweb
which would fix that, but I think some users would complain in that case.
Of course it's possible that we get compile errors on other platforms not directly supported, but I don't think we have to care about that (if someone needs support for another platform, they can make a PR to fix).
#[cfg(feature = "log")] #[macro_use] extern crate log; | ||
#[allow(unused)] | ||
#[cfg(not(feature = "log"))] macro_rules! trace { ($($x:tt)*) => () } | ||
#[allow(unused)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliantly simple fix! 👍
Yes they are 😄. In the end we should have 5 of them, 2 in
Yes, the ones that use
Doing it exactly with the whole cfg-list as in this PR looks heavy, but seems like the right solution to me. |
Ah, Okay, then I think we're ready to merge? |
I'd like to try it on the 0.5 branch first instead. Closing in favour of #512. |
This is (in my opinion) the proper fix for #503: make
OsRng
unavailable if the platform is not supported.This also makes
JitterRng::new
unavailable on Wasm.EntropyRng
already had tricky logic. Making it work nicely whenOsRng
and/orJitterRng
are not available at compile time complicates it further. And I didn't want to think how it was going to look when we want to add some configurable third entropy source.I have tried to rewrite
EntropyRng
to have hopefully simpler logic. Because we need wrappers forOsRng
andJitterRng
to make it compile on all platforms, I went all the way and added a little trait to ease implementation.