Skip to content

Commit

Permalink
Replace rand_os with getrandom (#90)
Browse files Browse the repository at this point in the history
`rand_os` is just a wrapper for `getrandom`. I believe the long term
plan is to deprecrate it entirely.
  • Loading branch information
tarcieri authored and liamsi committed Dec 11, 2019
1 parent 8630b32 commit db16953
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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

0 comments on commit db16953

Please sign in to comment.