Skip to content

Commit

Permalink
Bump rand crate to 0.6 (was 0.5) (mimblewimble#2790)
Browse files Browse the repository at this point in the history
shuffle was deprecated, fix this up
  • Loading branch information
antiochp authored and ignopeverell committed Apr 30, 2019
1 parent b2b96f3 commit 6352780
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 27 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ grin_util = { path = "../util", version = "1.1.0-beta.2" }

[dev-dependencies]
env_logger = "0.5"
rand = "0.5"
rand = "0.6"
2 changes: 1 addition & 1 deletion config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workspace = ".."
edition = "2018"

[dependencies]
rand = "0.5"
rand = "0.6"
serde = "1"
serde_derive = "1"
toml = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lazy_static = "1"
lru-cache = "0.1"
num = "0.2"
num-bigint = "0.2"
rand = "0.5"
rand = "0.6"
serde = "1"
serde_derive = "1"
siphasher = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion keychain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
[dependencies]
byteorder = "1"
blake2-rfc = "0.2"
rand = "0.5"
rand = "0.6"
log = "0.4"
serde = "1"
serde_derive = "1"
Expand Down
3 changes: 1 addition & 2 deletions p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bytes = "0.4"
enum_primitive = "0.1"
net2 = "0.2"
num = "0.1"
rand = "0.5"
rand = "0.6"
serde = "1"
serde_derive = "1"
log = "0.4"
Expand All @@ -28,4 +28,3 @@ grin_chain = { path = "../chain", version = "1.1.0-beta.2" }

[dev-dependencies]
grin_pool = { path = "../pool", version = "1.1.0-beta.2" }

9 changes: 5 additions & 4 deletions p2p/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use std::fs::File;
use std::path::PathBuf;
use std::sync::Arc;

use rand::{thread_rng, Rng};
use rand::seq::SliceRandom;
use rand::thread_rng;

use crate::chain;
use crate::core::core;
Expand Down Expand Up @@ -100,7 +101,7 @@ impl Peers {
.filter(|p| p.is_connected())
.cloned()
.collect::<Vec<_>>();
thread_rng().shuffle(&mut res);
res.shuffle(&mut thread_rng());
res
}

Expand Down Expand Up @@ -141,7 +142,7 @@ impl Peers {
.filter(|x| x.info.total_difficulty() > total_difficulty)
.collect::<Vec<_>>();

thread_rng().shuffle(&mut max_peers);
max_peers.shuffle(&mut thread_rng());
Ok(max_peers)
}

Expand Down Expand Up @@ -190,7 +191,7 @@ impl Peers {
.filter(|x| x.info.total_difficulty() == max_total_difficulty)
.collect::<Vec<_>>();

thread_rng().shuffle(&mut max_peers);
max_peers.shuffle(&mut thread_rng());
max_peers
}

Expand Down
5 changes: 3 additions & 2 deletions p2p/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
use chrono::Utc;
use num::FromPrimitive;
use rand::{thread_rng, Rng};
use rand::seq::SliceRandom;
use rand::thread_rng;

use crate::core::ser::{self, Readable, Reader, Writeable, Writer};
use crate::types::{Capabilities, PeerAddr, ReasonForBan};
Expand Down Expand Up @@ -158,7 +159,7 @@ impl PeerStore {
.map(|(_, v)| v)
.filter(|p| p.flags == state && p.capabilities.contains(cap))
.collect::<Vec<_>>();
thread_rng().shuffle(&mut peers[..]);
peers[..].shuffle(&mut thread_rng());
Ok(peers.iter().take(count).cloned().collect())
}

Expand Down
2 changes: 1 addition & 1 deletion pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
blake2-rfc = "0.2"
rand = "0.5"
rand = "0.6"
serde = "1"
serde_derive = "1"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ futures = "0.1"
http = "0.1"
itertools = "0.7"
lmdb-zero = "0.4.4"
rand = "0.5"
rand = "0.6"
serde = "1"
log = "0.4"
serde_derive = "1"
Expand Down
5 changes: 3 additions & 2 deletions servers/src/grin/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
use chrono::prelude::{DateTime, Utc};
use chrono::{Duration, MIN_DATE};
use rand::{thread_rng, Rng};
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::collections::HashMap;
use std::net::ToSocketAddrs;
use std::sync::{mpsc, Arc};
Expand Down Expand Up @@ -221,7 +222,7 @@ fn monitor_peers(
// take a random defunct peer and mark it healthy: over a long period any
// peer will see another as defunct eventually, gives us a chance to retry
if defuncts.len() > 0 {
thread_rng().shuffle(&mut defuncts);
defuncts.shuffle(&mut thread_rng());
let _ = peers.update_state(defuncts[0].addr, p2p::State::Healthy);
}

Expand Down
2 changes: 1 addition & 1 deletion store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ grin_util = { path = "../util", version = "1.1.0-beta.2" }

[dev-dependencies]
chrono = "0.4.4"
rand = "0.5"
rand = "0.6"
filetime = "0.2"
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ backtrace = "0.3"
base64 = "0.9"
byteorder = "1"
lazy_static = "1"
rand = "0.5"
rand = "0.6"
serde = "1"
serde_derive = "1"
log4rs = { version = "0.8.1", features = ["rolling_file_appender", "compound_policy", "size_trigger", "fixed_window_roller"] }
Expand Down

0 comments on commit 6352780

Please sign in to comment.