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

Replace rand_os with getrandom (closes #23) #90

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ bytes = "0.4"
bytes_0_5 = { version = "0.5", package = "bytes" }
chrono = { version = "0.4", features = ["serde"] }
failure = "0.1"
getrandom = "0.1"
http = "0.2"
hyper = "0.13"
prost-amino = { version = "0.4.0" }
prost-amino-derive = { version = "0.4.0" }
rand_os = { version = "0.1" }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
signatory = { version = "0.17", features = ["ed25519", "ecdsa"] }
Expand Down
5 changes: 2 additions & 3 deletions tendermint/src/rpc/id.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! JSONRPC IDs

use rand_os::{rand_core::RngCore, OsRng};
use getrandom::getrandom;
use serde::{Deserialize, Serialize};

/// JSONRPC ID: request-specific identifier
Expand All @@ -10,9 +10,8 @@ pub struct Id(String);
impl Id {
/// Create a JSONRPC ID containing a UUID v4 (i.e. random)
pub fn uuid_v4() -> Self {
let mut rng = OsRng::new().unwrap();
let mut bytes = [0; 16];
rng.fill_bytes(&mut bytes);
getrandom(&mut bytes).expect("RNG failure!");

let uuid = uuid::Builder::from_bytes(bytes)
.set_variant(uuid::Variant::RFC4122)
Expand Down