fix: account for rand crate changes
This commit is contained in:
2 files changed
+8
-9
No files matched your search
@@ -1,9 +1,8 @@
|
||||
use crate::netlink::{Netlink, NetlinkError, Qdisc};
|
||||
use crate::{Config, ReflectorStats};
|
||||
use log::{debug, error, info, warn};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use rand::RngCore;
|
||||
use rand::seq::IndexedRandom;
|
||||
use rand::{rng, RngCore};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
@@ -52,7 +51,7 @@ fn generate_initial_speeds(base_speed: f64, size: u32) -> Vec<f64> {
|
||||
let mut rates = Vec::new();
|
||||
|
||||
for _ in 0..size {
|
||||
rates.push((thread_rng().next_u64() as f64 * 0.2 + 0.75) * base_speed);
|
||||
rates.push((rng().next_u64() as f64 * 0.2 + 0.75) * base_speed);
|
||||
}
|
||||
|
||||
rates
|
||||
@@ -190,7 +189,7 @@ impl Ratecontroller {
|
||||
}
|
||||
|
||||
if state.delta_stat > delay_ms {
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
match state.safe_rates.choose(&mut rng) {
|
||||
Some(rnd_rate) => {
|
||||
state.next_rate =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{Config, ReflectorStats};
|
||||
use log::{debug, info};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::{thread_rng, Rng};
|
||||
use rand::{rng, Rng};
|
||||
use rand::seq::IndexedRandom;
|
||||
use std::collections::HashMap;
|
||||
use std::net::IpAddr;
|
||||
use std::sync::mpsc::Receiver;
|
||||
@@ -24,7 +24,7 @@ impl ReflectorSelector {
|
||||
let baseline_sleep_time =
|
||||
Duration::from_secs_f64(self.config.tick_interval * std::f64::consts::PI);
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
// Initial wait of several seconds to allow some OWD data to build up
|
||||
sleep(baseline_sleep_time);
|
||||
@@ -107,7 +107,7 @@ impl ReflectorSelector {
|
||||
|
||||
// Shuffle the deck so we avoid overwhelming good reflectors (Fisher-Yates)
|
||||
for i in (1_usize..candidates.len()).rev() {
|
||||
let j = rng.gen_range(0..(i + 1));
|
||||
let j = rng.random_range(0..(i + 1));
|
||||
candidates.swap(i, j);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user