diff --git a/src/config.rs b/src/config.rs index aa2a5d2..fde3224 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,6 +28,7 @@ pub struct Config { pub prob_connection_fails: f64, // If the connection fails, retry how many times? pub num_connection_retries: u32, + pub prob_user_connects: f64, pub prob_user_invites_friend: f64, pub prob_user_submits_reports: f64, pub prob_user_treats_throttling_as_blocking: f64, diff --git a/src/main.rs b/src/main.rs index 25a5f47..a77b127 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,7 @@ pub struct Config { pub one_positive_report_per_cred: bool, pub prob_censor_gets_invite: f64, pub prob_connection_fails: f64, + pub prob_user_connects: f64, pub prob_user_invites_friend: f64, pub prob_user_submits_reports: f64, pub prob_user_treats_throttling_as_blocking: f64, @@ -103,6 +104,7 @@ pub async fn main() { one_positive_report_per_cred: config.one_positive_report_per_cred, prob_censor_gets_invite: config.prob_censor_gets_invite, prob_connection_fails: config.prob_connection_fails, + prob_user_connects: config.prob_user_connects, prob_user_invites_friend: config.prob_user_invites_friend, prob_user_submits_reports: config.prob_user_submits_reports, prob_user_treats_throttling_as_blocking: config.prob_user_treats_throttling_as_blocking, diff --git a/src/user.rs b/src/user.rs index 5574925..652028b 100644 --- a/src/user.rs +++ b/src/user.rs @@ -59,7 +59,10 @@ pub struct User { // Does the user submit reports to Troll Patrol? submits_reports: bool, - // How likely is this user to use bridges on a given day? + // How likely is this user to use bridges on a given day? This has + // been converted to a global parameter (prob_user_connects), but we + // still leave the user implementation for now in case we want to + // switch back to it. prob_use_bridges: f64, // If the censor implements partial blocking, is the user blocked? @@ -90,8 +93,8 @@ impl User { let (prob_use_bridges, submits_reports) = if is_censor { (0.0, false) } else { - let mut rng = rand::thread_rng(); - let prob_use_bridges = rng.gen_range(0.0..=1.0); + // Use global value + let prob_use_bridges = config.prob_user_connects; let submits_reports = event_happens(config.prob_user_submits_reports); (prob_use_bridges, submits_reports) }; @@ -198,8 +201,8 @@ impl User { let (prob_use_bridges, submits_reports) = if is_censor { (0.0, false) } else { - let mut rng = rand::thread_rng(); - let prob_use_bridges = rng.gen_range(0.0..=1.0); + // Use global value + let prob_use_bridges = config.prob_user_connects; let submits_reports = event_happens(config.prob_user_submits_reports); (prob_use_bridges, submits_reports) };