Created
June 21, 2018 15:23
-
-
Save kpp/153ea0a4ddf2927f8d9e9e0bd7dfa447 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
humbug@home:~/zetox$ git diff | cat | |
diff --git a/Cargo.toml b/Cargo.toml | |
index 9206765..b4f0b15 100644 | |
--- a/Cargo.toml | |
+++ b/Cargo.toml | |
@@ -33,7 +33,7 @@ bytes = "0.4" | |
byteorder = "1" | |
futures = "0.1" | |
log = "0.4" | |
-sodiumoxide = "0.0.16" | |
+sodiumoxide = "0.1" | |
tokio = "0.1.7" | |
tokio-codec = "0.1" | |
nom = "3.2.1" | |
diff --git a/src/toxcore/crypto_core.rs b/src/toxcore/crypto_core.rs | |
index 8a3702b..f7cff64 100644 | |
--- a/src/toxcore/crypto_core.rs | |
+++ b/src/toxcore/crypto_core.rs | |
@@ -26,17 +26,12 @@ pub use sodiumoxide::crypto::box_::*; | |
pub use sodiumoxide::crypto::hash::{sha256, sha512}; | |
pub use sodiumoxide::crypto::secretbox; | |
-use std::sync::{Once, ONCE_INIT}; | |
use byteorder::{ByteOrder, NativeEndian}; | |
use toxcore::binary_io::*; | |
// TODO: check if `#[inline]` is actually useful | |
- | |
-static CRYPTO_INIT_ONCE: Once = ONCE_INIT; | |
-static mut CRYPTO_INIT: bool = false; | |
- | |
/** Run before using crypto. | |
Runs [`sodiumoxide::init()`](../../../sodiumoxide/fn.init.html). | |
@@ -54,14 +49,7 @@ assert_eq!(true, crypto_init()); | |
``` | |
*/ | |
pub fn crypto_init() -> bool { | |
- // NOTE: `init()` could be run more than once, but not in parallel, and | |
- // `CRYPTO_INIT` *can't* be modified while it may be read by | |
- // something else. | |
- CRYPTO_INIT_ONCE.call_once(|| { | |
- let initialized = ::sodiumoxide::init(); | |
- unsafe { CRYPTO_INIT = initialized; } | |
- }); | |
- unsafe { CRYPTO_INIT } | |
+ ::sodiumoxide::init().is_ok() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiling libsodium-sys v0.1.0 | |
Compiling sodiumoxide v0.1.0 | |
Compiling tox v0.0.4 (file:///home/humbug/zetox) | |
error[E0308]: mismatched types | |
--> src/toxcore/dht/codec.rs:91:74 | |
| | |
91 | IResult::Error(error) => Err(DecodeError::DeserializeError { error }.into()), | |
| ^^^^^ expected enum `nom::ErrorKind`, found enum `nom::Err` | |
| | |
= note: expected type `nom::ErrorKind` | |
found type `nom::Err<&[u8]>` | |
error: aborting due to previous error | |
For more information about this error, try `rustc --explain E0308`. | |
error: Could not compile `tox`. | |
To learn more, run the command again with --verbose. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment