|
@@ -41,6 +41,8 @@ pub struct Config {
|
|
|
// map of distributor name to IP:port to contact it
|
|
|
pub distributors: BTreeMap<BridgeDistributor, String>,
|
|
|
extra_infos_base_url: String,
|
|
|
+ // confidence required to consider a bridge blocked
|
|
|
+ confidence: f64,
|
|
|
//require_bridge_token: bool,
|
|
|
port: u16,
|
|
|
updater_schedule: String,
|
|
@@ -64,13 +66,14 @@ async fn update_daily_info(
|
|
|
db: &Db,
|
|
|
distributors: &BTreeMap<BridgeDistributor, String>,
|
|
|
extra_infos_base_url: &str,
|
|
|
+ confidence: f64,
|
|
|
) {
|
|
|
update_extra_infos(&db, &extra_infos_base_url)
|
|
|
.await
|
|
|
.unwrap();
|
|
|
update_negative_reports(&db, &distributors).await;
|
|
|
update_positive_reports(&db, &distributors).await;
|
|
|
- let new_blockages = guess_blockages(&db, &analyzer::ExampleAnalyzer {});
|
|
|
+ let new_blockages = guess_blockages(&db, &analyzer::ExampleAnalyzer {}, confidence);
|
|
|
report_blockages(&distributors, new_blockages).await;
|
|
|
}
|
|
|
|
|
@@ -82,11 +85,12 @@ async fn create_context_manager(
|
|
|
db_config: DbConfig,
|
|
|
distributors: BTreeMap<BridgeDistributor, String>,
|
|
|
extra_infos_base_url: &str,
|
|
|
+ confidence: f64,
|
|
|
context_rx: mpsc::Receiver<Command>,
|
|
|
mut kill: broadcast::Receiver<()>,
|
|
|
) {
|
|
|
tokio::select! {
|
|
|
- create_context = context_manager(db_config, distributors, extra_infos_base_url, context_rx) => create_context,
|
|
|
+ create_context = context_manager(db_config, distributors, extra_infos_base_url, confidence, context_rx) => create_context,
|
|
|
_ = kill.recv() => {println!("Shut down manager");},
|
|
|
}
|
|
|
}
|
|
@@ -95,6 +99,7 @@ async fn context_manager(
|
|
|
db_config: DbConfig,
|
|
|
distributors: BTreeMap<BridgeDistributor, String>,
|
|
|
extra_infos_base_url: &str,
|
|
|
+ confidence: f64,
|
|
|
mut context_rx: mpsc::Receiver<Command>,
|
|
|
) {
|
|
|
let db: Db = sled::open(&db_config.db_path).unwrap();
|
|
@@ -115,7 +120,7 @@ async fn context_manager(
|
|
|
println!("Shutdown Sent.");
|
|
|
}
|
|
|
Update {} => {
|
|
|
- update_daily_info(&db, &distributors, &extra_infos_base_url).await;
|
|
|
+ update_daily_info(&db, &distributors, &extra_infos_base_url, confidence).await;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -182,6 +187,7 @@ async fn main() {
|
|
|
config.db,
|
|
|
config.distributors,
|
|
|
&config.extra_infos_base_url,
|
|
|
+ config.confidence,
|
|
|
request_rx,
|
|
|
kill,
|
|
|
)
|