diff --git a/Cargo.lock b/Cargo.lock index 885237365..6a771511e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1593,6 +1593,18 @@ dependencies = [ "triggered", ] +[[package]] +name = "boosting-oracles" +version = "0.1.0" +dependencies = [ + "anyhow", + "helium-proto", + "hextree", + "rust_decimal", + "rust_decimal_macros", + "sqlx", +] + [[package]] name = "borsh" version = "0.9.3" @@ -4672,6 +4684,7 @@ dependencies = [ "async-trait", "backon", "base64 0.21.7", + "boosting-oracles", "chrono", "clap 4.4.8", "config", diff --git a/Cargo.toml b/Cargo.toml index 48b60ed99..2841d39d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ "reward_scheduler", "solana", "task_manager", + "boosting_oracles", ] resolver = "2" diff --git a/boosting_oracles/Cargo.toml b/boosting_oracles/Cargo.toml new file mode 100644 index 000000000..5a592901c --- /dev/null +++ b/boosting_oracles/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "boosting-oracles" +version = "0.1.0" +description = "Boosting Oracles" +edition.workspace = true +authors.workspace = true +license.workspace = true + +[dependencies] +anyhow = { workspace = true } +hextree = { workspace = true } +sqlx = {version = "*", features = ["runtime-tokio-rustls"]} +rust_decimal = { workspace = true} +rust_decimal_macros = { workspace = true} +helium-proto = {workspace = true} diff --git a/mobile_verifier/src/boosting_oracles/assignment.rs b/boosting_oracles/src/assignment.rs similarity index 100% rename from mobile_verifier/src/boosting_oracles/assignment.rs rename to boosting_oracles/src/assignment.rs diff --git a/mobile_verifier/src/boosting_oracles/mod.rs b/boosting_oracles/src/lib.rs similarity index 97% rename from mobile_verifier/src/boosting_oracles/mod.rs rename to boosting_oracles/src/lib.rs index 5b13f10af..b40f592c2 100644 --- a/mobile_verifier/src/boosting_oracles/mod.rs +++ b/boosting_oracles/src/lib.rs @@ -1,6 +1,7 @@ pub mod assignment; -use crate::Settings; +use std::path::PathBuf; + pub use assignment::{Assignment, HexAssignments}; use hextree::disktree::DiskTreeMap; @@ -14,10 +15,14 @@ pub struct HexBoostData { landtype: DiskTreeMap, } -pub fn make_hex_boost_data(settings: &Settings) -> anyhow::Result { - let urban_disktree = DiskTreeMap::open(&settings.urbanization_data_set)?; - let footfall_disktree = DiskTreeMap::open(&settings.footfall_data_set)?; - let landtype_disktree = DiskTreeMap::open(&settings.landtype_data_set)?; +pub fn make_hex_boost_data( + urbanization_data_set: &PathBuf, + footfall_data_set: &PathBuf, + landtype_data_set: &PathBuf, +) -> anyhow::Result { + let urban_disktree = DiskTreeMap::open(urbanization_data_set)?; + let footfall_disktree = DiskTreeMap::open(footfall_data_set)?; + let landtype_disktree = DiskTreeMap::open(landtype_data_set)?; let hex_boost_data = HexBoostData { urbanized: urban_disktree, diff --git a/mobile_verifier/Cargo.toml b/mobile_verifier/Cargo.toml index 00889525f..e0ec8836d 100644 --- a/mobile_verifier/Cargo.toml +++ b/mobile_verifier/Cargo.toml @@ -50,6 +50,7 @@ async-trait = {workspace = true} retainer = {workspace = true} uuid = {workspace = true} task-manager = {path = "../task_manager"} +boosting-oracles = {path = "../boosting_oracles"} solana-sdk = {workspace = true} [dev-dependencies] diff --git a/mobile_verifier/src/cli/server.rs b/mobile_verifier/src/cli/server.rs index 33381f2c8..31c0418e8 100644 --- a/mobile_verifier/src/cli/server.rs +++ b/mobile_verifier/src/cli/server.rs @@ -1,5 +1,4 @@ use crate::{ - boosting_oracles, coverage::CoverageDaemon, data_session::DataSessionIngestor, geofence::Geofence, @@ -11,6 +10,7 @@ use crate::{ telemetry, Settings, }; use anyhow::Result; +use boosting_oracles; use chrono::Duration; use file_store::{ file_sink, @@ -148,7 +148,11 @@ impl Cmd { file_upload.clone(), report_ingest.clone(), auth_client.clone(), - boosting_oracles::make_hex_boost_data(settings)?, + boosting_oracles::make_hex_boost_data( + &settings.urbanization_data_set, + &settings.footfall_data_set, + &settings.landtype_data_set, + )?, ) .await?, ) diff --git a/mobile_verifier/src/cli/verify_disktree.rs b/mobile_verifier/src/cli/verify_disktree.rs index 4c2aa4529..ee4e14a0a 100644 --- a/mobile_verifier/src/cli/verify_disktree.rs +++ b/mobile_verifier/src/cli/verify_disktree.rs @@ -2,10 +2,8 @@ use std::{collections::HashMap, path::PathBuf}; use hextree::disktree::DiskTreeMap; -use crate::{ - boosting_oracles::{Assignment, Landtype}, - Settings, -}; +use crate::Settings; +use boosting_oracles::{Assignment, Landtype}; #[derive(Debug, clap::Args)] pub struct Cmd { diff --git a/mobile_verifier/src/coverage.rs b/mobile_verifier/src/coverage.rs index 860005154..66220962d 100644 --- a/mobile_verifier/src/coverage.rs +++ b/mobile_verifier/src/coverage.rs @@ -1,8 +1,9 @@ use crate::{ - boosting_oracles::{BoostedHexAssignments, HexAssignments, HexBoostData}, heartbeats::{HbType, KeyType, OwnedKeyType}, IsAuthorized, Settings, }; +use boosting_oracles::{BoostedHexAssignments, HexAssignments, HexBoostData}; + use chrono::{DateTime, Duration, Utc}; use file_store::{ coverage::{self, CoverageObjectIngestReport}, diff --git a/mobile_verifier/src/lib.rs b/mobile_verifier/src/lib.rs index 82353ef52..9d456516e 100644 --- a/mobile_verifier/src/lib.rs +++ b/mobile_verifier/src/lib.rs @@ -1,4 +1,3 @@ -pub mod boosting_oracles; pub mod cell_type; pub mod cli; pub mod coverage;