Skip to content

Commit

Permalink
Maybe ban
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie committed Oct 11, 2024
1 parent afbbdf7 commit 038cf2a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions mobile_verifier/src/radio_location_estimates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ use helium_proto::services::{
};
use mobile_config::client::authorization_client::AuthorizationVerifier;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;
use sha2::{Digest, Sha256};
use sqlx::{Pool, Postgres, Transaction};
use task_manager::{ManagedTask, TaskManager};
use tokio::sync::mpsc::Receiver;

const CONFIDENCE_THRESHOLD: Decimal = dec!(0.75);

pub struct RadioLocationEstimatesDaemon<AV> {
pool: Pool<Postgres>,
authorization_verifier: AV,
Expand Down Expand Up @@ -130,6 +133,9 @@ where

if verified_report_status == RadioLocationEstimatesVerificationStatus::Valid {
save_to_db(&report, &mut transaction).await?;

// Once they are saved to DB should we directly write to ban table?
// maybe_ban_radios(&report, &mut transaction).await?;
}

let verified_report_proto: VerifiedRadioLocationEstimatesReportV1 =
Expand Down Expand Up @@ -205,6 +211,26 @@ async fn save_to_db(
Ok(())
}

// TODO: knowing that radio could also be a PublicKey for wifi hotspot.
// Should we make radio_id in report a binary or some kind of proto enum to have one or other?

// async fn maybe_ban_radios(
// report: &RadioLocationEstimatesIngestReport,
// exec: &mut Transaction<'_, Postgres>,
// ) -> Result<(), sqlx::Error> {
// let estimates = &report.report.estimates;
// let radio_id = &report.report.radio_id;
// let mut will_ban = true;

// for estimate in estimates {
// if estimate.confidence > CONFIDENCE_THRESHOLD {
// will_ban = false;
// }
// }

// Ok(())
// }

async fn invalidate_old_estimates(
radio_id: String,
timestamp: DateTime<Utc>,
Expand Down

0 comments on commit 038cf2a

Please sign in to comment.