Compare commits
2 Commits
d9aa616d77
...
659b8fa16c
Author | SHA1 | Date |
---|---|---|
|
659b8fa16c | |
|
6b6836dbae |
109
src/analysis.rs
109
src/analysis.rs
|
@ -309,35 +309,44 @@ impl Analyzer for NormalAnalyzer {
|
||||||
|
|
||||||
let alpha = 1.0 - confidence;
|
let alpha = 1.0 - confidence;
|
||||||
|
|
||||||
let (bridge_ips_mean, bridge_ips_sd) = Self::mean_and_std_dev(bridge_ips);
|
// Evaluate based on negative reports
|
||||||
let (negative_reports_mean, negative_reports_sd) = Self::mean_and_std_dev(negative_reports);
|
let (negative_reports_mean, negative_reports_sd) = Self::mean_and_std_dev(negative_reports);
|
||||||
|
|
||||||
// Model negative reports separately
|
|
||||||
let bip_normal = Normal::new(bridge_ips_mean, bridge_ips_sd);
|
|
||||||
let nr_normal = Normal::new(negative_reports_mean, negative_reports_sd);
|
let nr_normal = Normal::new(negative_reports_mean, negative_reports_sd);
|
||||||
|
if negative_reports_sd > 0.0 {
|
||||||
// If we have 0 standard deviation, we need another way to
|
|
||||||
// evaluate each variable
|
|
||||||
let bip_test = if bridge_ips_sd > 0.0 {
|
|
||||||
bip_normal.unwrap().cdf(bridge_ips_today as f64) < alpha
|
|
||||||
} else {
|
|
||||||
// Consider the bridge blocked if its usage dropped by more
|
|
||||||
// than 1 bin. (Note that the mean is the exact value
|
|
||||||
// because we had no deviation.)
|
|
||||||
(bridge_ips_today as f64) < bridge_ips_mean - 8.0
|
|
||||||
};
|
|
||||||
let nr_test = if negative_reports_sd > 0.0 {
|
|
||||||
// We use CCDF because more negative reports is worse.
|
// We use CCDF because more negative reports is worse.
|
||||||
(1.0 - nr_normal.unwrap().cdf(negative_reports_today as f64)) < alpha
|
if (1.0 - nr_normal.unwrap().cdf(negative_reports_today as f64)) < alpha {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// If the standard deviation is 0, we need another option.
|
||||||
// Consider the bridge blocked negative reports increase by
|
// Consider the bridge blocked negative reports increase by
|
||||||
// more than 1 after a long static period. (Note that the
|
// more than 1 after a long static period. (Note that the
|
||||||
// mean is the exact value because we had no deviation.)
|
// mean is the exact value because we had no deviation.)
|
||||||
(negative_reports_today as f64) > negative_reports_mean + 1.0
|
if (negative_reports_today as f64) > negative_reports_mean + 1.0 {
|
||||||
};
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if any test concluded the bridge is blocked
|
// Evaluate based on bridge stats
|
||||||
bip_test || nr_test
|
let (bridge_ips_mean, bridge_ips_sd) = Self::mean_and_std_dev(bridge_ips);
|
||||||
|
let bip_normal = Normal::new(bridge_ips_mean, bridge_ips_sd);
|
||||||
|
if bridge_ips_sd > 0.0 {
|
||||||
|
if bip_normal.unwrap().cdf(bridge_ips_today as f64) < alpha {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If the standard deviation is 0, we need another option.
|
||||||
|
// Consider the bridge blocked if its usage dropped by more
|
||||||
|
// than 1 bin. (Note that the mean is the exact value
|
||||||
|
// because we had no deviation.)
|
||||||
|
if (bridge_ips_today as f64) < bridge_ips_mean - 8.0 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If none of the tests concluded that the bridge is blocked,
|
||||||
|
// return false
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate invite-only bridge with lv3+ users submitting positive reports
|
/// Evaluate invite-only bridge with lv3+ users submitting positive reports
|
||||||
|
@ -357,19 +366,29 @@ impl Analyzer for NormalAnalyzer {
|
||||||
|
|
||||||
let alpha = 1.0 - confidence;
|
let alpha = 1.0 - confidence;
|
||||||
|
|
||||||
// Model bridge IPs and positive reports with multivariate
|
// Evaluate based on negative reports. It is better to compute
|
||||||
// normal distribution
|
// negative reports test first because the positive test may be
|
||||||
let (mean_vec, cov_mat) = Self::stats(&[bridge_ips, positive_reports]);
|
// expensive.
|
||||||
let mvn = MultivariateNormal::new(mean_vec, cov_mat);
|
|
||||||
|
|
||||||
// Model negative reports separately
|
|
||||||
let (negative_reports_mean, negative_reports_sd) = Self::mean_and_std_dev(negative_reports);
|
let (negative_reports_mean, negative_reports_sd) = Self::mean_and_std_dev(negative_reports);
|
||||||
let nr_normal = Normal::new(negative_reports_mean, negative_reports_sd);
|
let nr_normal = Normal::new(negative_reports_mean, negative_reports_sd);
|
||||||
|
if negative_reports_sd > 0.0 {
|
||||||
|
// We use CCDF because more negative reports is worse.
|
||||||
|
if (1.0 - nr_normal.unwrap().cdf(negative_reports_today as f64)) < alpha {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Consider the bridge blocked negative reports increase by
|
||||||
|
// more than 1 after a long static period. (Note that the
|
||||||
|
// mean is the exact value because we had no deviation.)
|
||||||
|
if (negative_reports_today as f64) > negative_reports_mean + 1.0 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we have 0 standard deviation or a covariance matrix that
|
// Evaluate based on bridge stats and positive reports.
|
||||||
// is not positive definite, we need another way to evaluate
|
let (mean_vec, cov_mat) = Self::stats(&[bridge_ips, positive_reports]);
|
||||||
// each variable
|
let mvn = MultivariateNormal::new(mean_vec, cov_mat);
|
||||||
let positive_test = if mvn.is_ok() {
|
if mvn.is_ok() {
|
||||||
let mvn = mvn.unwrap();
|
let mvn = mvn.unwrap();
|
||||||
|
|
||||||
// Estimate the CDF by integrating the PDF by hand with step
|
// Estimate the CDF by integrating the PDF by hand with step
|
||||||
|
@ -380,27 +399,27 @@ impl Analyzer for NormalAnalyzer {
|
||||||
cdf += mvn.pdf(&DVector::from_vec(vec![bip as f64, pr as f64]));
|
cdf += mvn.pdf(&DVector::from_vec(vec![bip as f64, pr as f64]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdf < alpha
|
if cdf < alpha {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Ignore positive reports and compute as in stage 2
|
// If we have 0 standard deviation or a covariance matrix
|
||||||
self.stage_two(
|
// that is not positive definite, we need another way to
|
||||||
|
// evaluate each variable. Ignore positive reports and
|
||||||
|
// compute as in stage 2
|
||||||
|
if self.stage_two(
|
||||||
confidence,
|
confidence,
|
||||||
bridge_ips,
|
bridge_ips,
|
||||||
bridge_ips_today,
|
bridge_ips_today,
|
||||||
negative_reports,
|
negative_reports,
|
||||||
negative_reports_today,
|
negative_reports_today,
|
||||||
)
|
) {
|
||||||
};
|
return true;
|
||||||
let nr_test = if negative_reports_sd > 0.0 {
|
}
|
||||||
// We use CCDF because more negative reports is worse.
|
|
||||||
(1.0 - nr_normal.unwrap().cdf(negative_reports_today as f64)) < alpha
|
|
||||||
} else {
|
|
||||||
// Consider the bridge blocked negative reports increase by
|
|
||||||
// more than 1 after a long static period. (Note that the
|
|
||||||
// mean is the exact value because we had no deviation.)
|
|
||||||
(negative_reports_today as f64) > negative_reports_mean + 1.0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
positive_test || nr_test
|
// If none of the tests concluded that the bridge is blocked,
|
||||||
|
// return false
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ pub struct User {
|
||||||
|
|
||||||
// Does the user submit reports to Troll Patrol?
|
// Does the user submit reports to Troll Patrol?
|
||||||
submits_reports: bool,
|
submits_reports: bool,
|
||||||
|
|
||||||
|
// How likely is this user to use bridges on a given day?
|
||||||
|
prob_use_bridges: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
|
@ -63,12 +66,17 @@ impl User {
|
||||||
cc
|
cc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Randomly determine how likely this user is to use bridges on
|
||||||
|
// a given day
|
||||||
|
let prob_use_bridges = rng.gen_range(0.0..=1.0);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
censor: censor,
|
censor: censor,
|
||||||
country: cc,
|
country: cc,
|
||||||
primary_cred: cred,
|
primary_cred: cred,
|
||||||
secondary_cred: None,
|
secondary_cred: None,
|
||||||
submits_reports: submits_reports,
|
submits_reports: submits_reports,
|
||||||
|
prob_use_bridges: prob_use_bridges,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,12 +135,17 @@ impl User {
|
||||||
cc
|
cc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Randomly determine how likely this user is to use bridges on
|
||||||
|
// a given day
|
||||||
|
let prob_use_bridges = rng.gen_range(0.0..=1.0);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
censor: censor,
|
censor: censor,
|
||||||
country: cc,
|
country: cc,
|
||||||
primary_cred: friend_cred,
|
primary_cred: friend_cred,
|
||||||
secondary_cred: None,
|
secondary_cred: None,
|
||||||
submits_reports: submits_reports,
|
submits_reports: submits_reports,
|
||||||
|
prob_use_bridges: prob_use_bridges,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,180 +192,189 @@ impl User {
|
||||||
// newly invited friends and a vector of fingerprints of successfully
|
// newly invited friends and a vector of fingerprints of successfully
|
||||||
// contacted bridges.
|
// contacted bridges.
|
||||||
pub async fn daily_tasks(&mut self, state: &State) -> (Vec<User>, Vec<[u8; 20]>) {
|
pub async fn daily_tasks(&mut self, state: &State) -> (Vec<User>, Vec<[u8; 20]>) {
|
||||||
// Download bucket to see if bridge is still reachable
|
// Probabilistically decide if the user should use bridges today
|
||||||
// (We assume that this step can be done even if the user can't actually
|
let mut rng = rand::thread_rng();
|
||||||
// talk to the LA.)
|
let num: f64 = rng.gen_range(0.0..1.0);
|
||||||
let (bucket, reachcred) = get_bucket(&state.net, &self.primary_cred).await;
|
if num < self.prob_use_bridges {
|
||||||
let level = scalar_u32(&self.primary_cred.trust_level).unwrap();
|
// Download bucket to see if bridge is still reachable
|
||||||
|
// (We assume that this step can be done even if the user can't actually
|
||||||
|
// talk to the LA.)
|
||||||
|
let (bucket, reachcred) = get_bucket(&state.net, &self.primary_cred).await;
|
||||||
|
let level = scalar_u32(&self.primary_cred.trust_level).unwrap();
|
||||||
|
|
||||||
// Can we level up the main credential?
|
// Can we level up the main credential?
|
||||||
let can_level_up = reachcred.is_some()
|
let can_level_up = reachcred.is_some()
|
||||||
&& (level == 0 && eligible_for_trust_promotion(&state.net, &self.primary_cred).await
|
&& (level == 0
|
||||||
|| level > 0 && eligible_for_level_up(&state.net, &self.primary_cred).await);
|
&& eligible_for_trust_promotion(&state.net, &self.primary_cred).await
|
||||||
|
|| level > 0 && eligible_for_level_up(&state.net, &self.primary_cred).await);
|
||||||
|
|
||||||
// Can we migrate the main credential?
|
// Can we migrate the main credential?
|
||||||
let can_migrate = reachcred.is_none() && level >= MIN_TRUST_LEVEL;
|
let can_migrate = reachcred.is_none() && level >= MIN_TRUST_LEVEL;
|
||||||
|
|
||||||
// Can we level up the secondary credential?
|
// Can we level up the secondary credential?
|
||||||
let mut second_level_up = false;
|
let mut second_level_up = false;
|
||||||
|
|
||||||
let mut failed = Vec::<BridgeLine>::new();
|
let mut failed = Vec::<BridgeLine>::new();
|
||||||
let mut succeeded = Vec::<BridgeLine>::new();
|
let mut succeeded = Vec::<BridgeLine>::new();
|
||||||
for i in 0..bucket.len() {
|
for i in 0..bucket.len() {
|
||||||
// At level 0, we only have 1 bridge
|
// At level 0, we only have 1 bridge
|
||||||
if level > 0 || i == 0 {
|
if level > 0 || i == 0 {
|
||||||
if self.connect(&bucket[i]) {
|
if self.connect(&bucket[i]) {
|
||||||
succeeded.push(bucket[i]);
|
succeeded.push(bucket[i]);
|
||||||
|
} else {
|
||||||
|
failed.push(bucket[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let second_cred = if succeeded.len() < 1 {
|
||||||
|
if self.secondary_cred.is_some() {
|
||||||
|
std::mem::replace(&mut self.secondary_cred, None)
|
||||||
} else {
|
} else {
|
||||||
failed.push(bucket[i]);
|
// Get new credential
|
||||||
}
|
let cred = get_lox_credential(
|
||||||
}
|
&state.net,
|
||||||
}
|
&get_open_invitation(&state.net).await,
|
||||||
let second_cred = if succeeded.len() < 1 {
|
get_lox_pub(&state.la_pubkeys),
|
||||||
if self.secondary_cred.is_some() {
|
)
|
||||||
std::mem::replace(&mut self.secondary_cred, None)
|
.await
|
||||||
} else {
|
.0;
|
||||||
// Get new credential
|
Some(cred)
|
||||||
let cred = get_lox_credential(
|
|
||||||
&state.net,
|
|
||||||
&get_open_invitation(&state.net).await,
|
|
||||||
get_lox_pub(&state.la_pubkeys),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.0;
|
|
||||||
Some(cred)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If we're able to connect with the primary credential, don't
|
|
||||||
// keep a secondary one.
|
|
||||||
None
|
|
||||||
};
|
|
||||||
if second_cred.is_some() {
|
|
||||||
let second_cred = second_cred.as_ref().unwrap();
|
|
||||||
let (second_bucket, second_reachcred) = get_bucket(&state.net, &second_cred).await;
|
|
||||||
if self.connect(&second_bucket[0]) {
|
|
||||||
succeeded.push(second_bucket[0]);
|
|
||||||
if second_reachcred.is_some()
|
|
||||||
&& eligible_for_trust_promotion(&state.net, &second_cred).await
|
|
||||||
{
|
|
||||||
second_level_up = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
failed.push(second_bucket[0]);
|
// If we're able to connect with the primary credential, don't
|
||||||
}
|
// keep a secondary one.
|
||||||
}
|
None
|
||||||
|
};
|
||||||
let mut negative_reports = Vec::<NegativeReport>::new();
|
if second_cred.is_some() {
|
||||||
let mut positive_reports = Vec::<PositiveReport>::new();
|
let second_cred = second_cred.as_ref().unwrap();
|
||||||
if self.submits_reports {
|
let (second_bucket, second_reachcred) = get_bucket(&state.net, &second_cred).await;
|
||||||
for bridge in &failed {
|
if self.connect(&second_bucket[0]) {
|
||||||
negative_reports.push(NegativeReport::from_bridgeline(
|
succeeded.push(second_bucket[0]);
|
||||||
*bridge,
|
if second_reachcred.is_some()
|
||||||
self.country.to_string(),
|
&& eligible_for_trust_promotion(&state.net, &second_cred).await
|
||||||
BridgeDistributor::Lox,
|
{
|
||||||
));
|
second_level_up = true;
|
||||||
}
|
}
|
||||||
if level >= 3 {
|
} else {
|
||||||
for bridge in &succeeded {
|
failed.push(second_bucket[0]);
|
||||||
positive_reports.push(
|
|
||||||
PositiveReport::from_lox_credential(
|
|
||||||
bridge.fingerprint,
|
|
||||||
None,
|
|
||||||
&self.primary_cred,
|
|
||||||
get_lox_pub(&state.la_pubkeys),
|
|
||||||
self.country.to_string(),
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// We might restrict these steps to succeeded.len() > 0, but we do
|
let mut negative_reports = Vec::<NegativeReport>::new();
|
||||||
// assume the user can contact the LA somehow, so let's just allow it.
|
let mut positive_reports = Vec::<PositiveReport>::new();
|
||||||
if can_level_up {
|
if self.submits_reports {
|
||||||
let cred = level_up(
|
for bridge in &failed {
|
||||||
&state.net,
|
negative_reports.push(NegativeReport::from_bridgeline(
|
||||||
&self.primary_cred,
|
*bridge,
|
||||||
&reachcred.unwrap(),
|
self.country.to_string(),
|
||||||
get_lox_pub(&state.la_pubkeys),
|
BridgeDistributor::Lox,
|
||||||
get_reachability_pub(&state.la_pubkeys),
|
));
|
||||||
)
|
}
|
||||||
.await;
|
if level >= 3 {
|
||||||
self.primary_cred = cred;
|
for bridge in &succeeded {
|
||||||
self.secondary_cred = None;
|
positive_reports.push(
|
||||||
}
|
PositiveReport::from_lox_credential(
|
||||||
// We favor starting over at level 1 to migrating
|
bridge.fingerprint,
|
||||||
else if second_level_up {
|
None,
|
||||||
let second_cred = second_cred.as_ref().unwrap();
|
&self.primary_cred,
|
||||||
let cred = trust_migration(
|
get_lox_pub(&state.la_pubkeys),
|
||||||
&state.net,
|
self.country.to_string(),
|
||||||
&second_cred,
|
)
|
||||||
&trust_promotion(&state.net, &second_cred, get_lox_pub(&state.la_pubkeys)).await,
|
.unwrap(),
|
||||||
get_lox_pub(&state.la_pubkeys),
|
);
|
||||||
get_migration_pub(&state.la_pubkeys),
|
}
|
||||||
)
|
}
|
||||||
.await;
|
}
|
||||||
self.primary_cred = cred;
|
|
||||||
self.secondary_cred = None;
|
// We might restrict these steps to succeeded.len() > 0, but we do
|
||||||
} else if can_migrate {
|
// assume the user can contact the LA somehow, so let's just allow it.
|
||||||
let cred = blockage_migration(
|
if can_level_up {
|
||||||
&state.net,
|
let cred = level_up(
|
||||||
&self.primary_cred,
|
|
||||||
&check_blockage(
|
|
||||||
&state.net,
|
&state.net,
|
||||||
&self.primary_cred,
|
&self.primary_cred,
|
||||||
|
&reachcred.unwrap(),
|
||||||
get_lox_pub(&state.la_pubkeys),
|
get_lox_pub(&state.la_pubkeys),
|
||||||
|
get_reachability_pub(&state.la_pubkeys),
|
||||||
)
|
)
|
||||||
.await,
|
.await;
|
||||||
get_lox_pub(&state.la_pubkeys),
|
self.primary_cred = cred;
|
||||||
get_migration_pub(&state.la_pubkeys),
|
self.secondary_cred = None;
|
||||||
)
|
}
|
||||||
.await;
|
// We favor starting over at level 1 to migrating
|
||||||
self.primary_cred = cred;
|
else if second_level_up {
|
||||||
self.secondary_cred = None;
|
let second_cred = second_cred.as_ref().unwrap();
|
||||||
} else if second_cred.is_some() {
|
let cred = trust_migration(
|
||||||
// Couldn't connect with primary credential
|
&state.net,
|
||||||
if succeeded.len() > 0 {
|
&second_cred,
|
||||||
// Keep the second credential only if it's useful
|
&trust_promotion(&state.net, &second_cred, get_lox_pub(&state.la_pubkeys))
|
||||||
self.secondary_cred = second_cred;
|
.await,
|
||||||
|
get_lox_pub(&state.la_pubkeys),
|
||||||
|
get_migration_pub(&state.la_pubkeys),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
self.primary_cred = cred;
|
||||||
|
self.secondary_cred = None;
|
||||||
|
} else if can_migrate {
|
||||||
|
let cred = blockage_migration(
|
||||||
|
&state.net,
|
||||||
|
&self.primary_cred,
|
||||||
|
&check_blockage(
|
||||||
|
&state.net,
|
||||||
|
&self.primary_cred,
|
||||||
|
get_lox_pub(&state.la_pubkeys),
|
||||||
|
)
|
||||||
|
.await,
|
||||||
|
get_lox_pub(&state.la_pubkeys),
|
||||||
|
get_migration_pub(&state.la_pubkeys),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
self.primary_cred = cred;
|
||||||
|
self.secondary_cred = None;
|
||||||
|
} else if second_cred.is_some() {
|
||||||
|
// Couldn't connect with primary credential
|
||||||
|
if succeeded.len() > 0 {
|
||||||
|
// Keep the second credential only if it's useful
|
||||||
|
self.secondary_cred = second_cred;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if negative_reports.len() > 0 {
|
if negative_reports.len() > 0 {
|
||||||
Self::send_negative_reports(&state, negative_reports).await;
|
Self::send_negative_reports(&state, negative_reports).await;
|
||||||
}
|
}
|
||||||
if positive_reports.len() > 0 {
|
if positive_reports.len() > 0 {
|
||||||
Self::send_positive_reports(&state, positive_reports).await;
|
Self::send_positive_reports(&state, positive_reports).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invite friends if applicable
|
// Invite friends if applicable
|
||||||
let invitations = scalar_u32(&self.primary_cred.invites_remaining).unwrap();
|
let invitations = scalar_u32(&self.primary_cred.invites_remaining).unwrap();
|
||||||
let mut new_friends = Vec::<User>::new();
|
let mut new_friends = Vec::<User>::new();
|
||||||
for _i in 0..invitations {
|
for _i in 0..invitations {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let num: f64 = rng.gen_range(0.0..1.0);
|
let num: f64 = rng.gen_range(0.0..1.0);
|
||||||
if num < state.prob_user_invites_friend {
|
if num < state.prob_user_invites_friend {
|
||||||
match self.invite(&state).await {
|
match self.invite(&state).await {
|
||||||
Ok(friend) => {
|
Ok(friend) => {
|
||||||
// You really shouldn't push your friends, especially
|
// You really shouldn't push your friends, especially
|
||||||
// new ones whose boundaries you might not know well.
|
// new ones whose boundaries you might not know well.
|
||||||
new_friends.push(friend);
|
new_friends.push(friend);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// List of fingerprints we contacted. This should not actually be more
|
// List of fingerprints we contacted. This should not actually be more
|
||||||
// than one.
|
// than one.
|
||||||
let mut connections = Vec::<[u8; 20]>::new();
|
let mut connections = Vec::<[u8; 20]>::new();
|
||||||
for bridge in succeeded {
|
for bridge in succeeded {
|
||||||
connections.push(bridge.get_hashed_fingerprint());
|
connections.push(bridge.get_hashed_fingerprint());
|
||||||
}
|
}
|
||||||
|
|
||||||
(new_friends, connections)
|
(new_friends, connections)
|
||||||
|
} else {
|
||||||
|
(Vec::<User>::new(), Vec::<[u8; 20]>::new())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue