From d0b45a4d9e2d3435a18bfbe7089449715e4ee505 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Thu, 6 Jun 2024 12:03:14 -0400 Subject: [PATCH 1/2] Change coverage map to treat hotspot_key as bytes rather than a PublicKeyBinary --- Cargo.lock | 1 - coverage_map/Cargo.toml | 1 - coverage_map/src/indoor.rs | 22 +++------ coverage_map/src/lib.rs | 90 +++++++++++++------------------------ coverage_map/src/outdoor.rs | 12 ++--- 5 files changed, 41 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da0281013..5e987f0ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2127,7 +2127,6 @@ version = "0.1.0" dependencies = [ "chrono", "h3o", - "helium-crypto", "helium-proto", "hex-assignments", "hextree", diff --git a/coverage_map/Cargo.toml b/coverage_map/Cargo.toml index d08ec321e..c9716d26f 100644 --- a/coverage_map/Cargo.toml +++ b/coverage_map/Cargo.toml @@ -10,7 +10,6 @@ edition.workspace = true [dependencies] chrono = { workspace = true } h3o = { workspace = true } -helium-crypto = { workspace = true } helium-proto = { workspace = true } hex-assignments = { path = "../hex_assignments" } hextree = { workspace = true } diff --git a/coverage_map/src/indoor.rs b/coverage_map/src/indoor.rs index 46442d929..5cbd0ed56 100644 --- a/coverage_map/src/indoor.rs +++ b/coverage_map/src/indoor.rs @@ -4,7 +4,6 @@ use std::{ }; use chrono::{DateTime, Utc}; -use helium_crypto::PublicKeyBinary; use hex_assignments::assignment::HexAssignments; use hextree::Cell; @@ -14,7 +13,7 @@ pub type IndoorCellTree = HashMap, cbsd_id: Option, seniority_timestamp: DateTime, signal_level: SignalLevel, @@ -53,7 +52,7 @@ pub fn insert_indoor_coverage_object(indoor: &mut IndoorCellTree, coverage_objec pub fn insert_indoor_coverage( indoor: &mut IndoorCellTree, - hotspot: &PublicKeyBinary, + hotspot: &[u8], cbsd_id: &Option, seniority_timestamp: DateTime, hex_coverage: UnrankedCoverage, @@ -64,7 +63,7 @@ pub fn insert_indoor_coverage( .entry(hex_coverage.signal_level) .or_default() .push(IndoorCoverageLevel { - hotspot_key: hotspot.clone(), + hotspot_key: hotspot.to_vec(), cbsd_id: cbsd_id.clone(), seniority_timestamp, signal_level: hex_coverage.signal_level, @@ -234,12 +233,9 @@ mod test { } fn indoor_cbrs_coverage(cbsd_id: &str, signal_level: SignalLevel) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: true, - hotspot_key: owner, + hotspot_key: vec![1, 0], seniority_timestamp: Utc::now(), cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { @@ -256,12 +252,9 @@ mod test { signal_level: SignalLevel, seniority_timestamp: DateTime, ) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: true, - hotspot_key: owner, + hotspot_key: vec![1, 0], seniority_timestamp, cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { @@ -278,12 +271,9 @@ mod test { location: Cell, seniority_timestamp: DateTime, ) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: true, - hotspot_key: owner, + hotspot_key: vec![1, 0], seniority_timestamp, cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { diff --git a/coverage_map/src/lib.rs b/coverage_map/src/lib.rs index 3a565a1be..fc4d13618 100644 --- a/coverage_map/src/lib.rs +++ b/coverage_map/src/lib.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, num::NonZeroU32}; use chrono::{DateTime, Utc}; -use helium_crypto::PublicKeyBinary; use hex_assignments::assignment::HexAssignments; use hextree::Cell; @@ -120,14 +119,14 @@ impl CoverageMapBuilder { /// Data structure from mapping radios to their ranked hex coverage #[derive(Clone, Default, Debug)] pub struct CoverageMap { - wifi_hotspots: HashMap>, + wifi_hotspots: HashMap, Vec>, cbrs_radios: HashMap>, } impl CoverageMap { /// Returns the hexes covered by the WiFi hotspot. The returned slice can be empty, indicating that /// the hotspot did not meet the criteria to be ranked in any hex. - pub fn get_wifi_coverage(&self, wifi_hotspot: &PublicKeyBinary) -> &[RankedCoverage] { + pub fn get_wifi_coverage(&self, wifi_hotspot: &[u8]) -> &[RankedCoverage] { self.wifi_hotspots .get(wifi_hotspot) .map(Vec::as_slice) @@ -148,7 +147,7 @@ impl CoverageMap { #[derive(Clone, Debug)] pub struct CoverageObject { pub indoor: bool, - pub hotspot_key: PublicKeyBinary, + pub hotspot_key: Vec, pub cbsd_id: Option, pub seniority_timestamp: DateTime, pub coverage: Vec, @@ -168,7 +167,7 @@ pub struct UnrankedCoverage { pub struct RankedCoverage { pub hex: Cell, pub rank: usize, - pub hotspot_key: PublicKeyBinary, + pub hotspot_key: Vec, pub cbsd_id: Option, pub assignments: HexAssignments, pub boosted: Option, @@ -233,41 +232,33 @@ mod test { #[test] fn test_indoor_wifi_submap() { + let radio1 = vec![1, 1, 1]; + let radio2 = vec![1, 1, 2]; + let radio3 = vec![1, 1, 3]; + let mut coverage_map_builder = CoverageMapBuilder::default(); coverage_map_builder.insert_coverage_object(indoor_wifi_coverage( - "11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9", + &radio1, 0x8a1fb46622dffff, SignalLevel::High, )); coverage_map_builder.insert_coverage_object(indoor_wifi_coverage( - "11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR", + &radio2, 0x8c2681a3064d9ff, SignalLevel::Low, )); let submap_builder = coverage_map_builder.submap(vec![indoor_wifi_coverage( - "11ibmJmQXTL6qMh4cq9pJ7tUtrpafWaVjjT6qhY7CNvjyvY9g1", + &radio3, 0x8c2681a3064d9ff, SignalLevel::High, )]); let submap = submap_builder.build(&NoBoostedHexes, Utc::now()); - let cov_1 = submap.get_wifi_coverage( - &"11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9" - .parse() - .unwrap(), - ); + let cov_1 = submap.get_wifi_coverage(&radio1); assert_eq!(cov_1.len(), 0); - let cov_2 = submap.get_wifi_coverage( - &"11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR" - .parse() - .unwrap(), - ); + let cov_2 = submap.get_wifi_coverage(&radio2); assert_eq!(cov_2.len(), 1); assert_eq!(cov_2[0].rank, 2); - let cov_3 = submap.get_wifi_coverage( - &"11ibmJmQXTL6qMh4cq9pJ7tUtrpafWaVjjT6qhY7CNvjyvY9g1" - .parse() - .unwrap(), - ); + let cov_3 = submap.get_wifi_coverage(&radio3); assert_eq!(cov_3.len(), 1); assert_eq!(cov_3[0].rank, 1); } @@ -300,41 +291,30 @@ mod test { #[test] fn test_outdoor_wifi_submap() { + let radio1 = vec![1, 1, 1]; + let radio2 = vec![1, 1, 2]; + let radio3 = vec![1, 1, 3]; + let mut coverage_map_builder = CoverageMapBuilder::default(); coverage_map_builder.insert_coverage_object(outdoor_wifi_coverage( - "11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9", + &radio1, 0x8a1fb46622dffff, 3, )); coverage_map_builder.insert_coverage_object(outdoor_wifi_coverage( - "11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR", + &radio2, 0x8c2681a3064d9ff, 1, )); - let submap_builder = coverage_map_builder.submap(vec![outdoor_wifi_coverage( - "11ibmJmQXTL6qMh4cq9pJ7tUtrpafWaVjjT6qhY7CNvjyvY9g1", - 0x8c2681a3064d9ff, - 2, - )]); + let submap_builder = + coverage_map_builder.submap(vec![outdoor_wifi_coverage(&radio3, 0x8c2681a3064d9ff, 2)]); let submap = submap_builder.build(&NoBoostedHexes, Utc::now()); - let cov_1 = submap.get_wifi_coverage( - &"11xtYwQYnvkFYnJ9iZ8kmnetYKwhdi87Mcr36e1pVLrhBMPLjV9" - .parse() - .unwrap(), - ); + let cov_1 = submap.get_wifi_coverage(&radio1); assert_eq!(cov_1.len(), 0); - let cov_2 = submap.get_wifi_coverage( - &"11PGVtgW9aM9ynfvns5USUsynYQ7EsMpxVqWuDKqFogKQX7etkR" - .parse() - .unwrap(), - ); + let cov_2 = submap.get_wifi_coverage(&radio2); assert_eq!(cov_2.len(), 1); assert_eq!(cov_2[0].rank, 2); - let cov_3 = submap.get_wifi_coverage( - &"11ibmJmQXTL6qMh4cq9pJ7tUtrpafWaVjjT6qhY7CNvjyvY9g1" - .parse() - .unwrap(), - ); + let cov_3 = submap.get_wifi_coverage(&radio3); assert_eq!(cov_3.len(), 1); assert_eq!(cov_3[0].rank, 1); } @@ -348,12 +328,9 @@ mod test { } fn indoor_cbrs_coverage(cbsd_id: &str, hex: u64, signal_level: SignalLevel) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: true, - hotspot_key: owner, + hotspot_key: vec![1, 0], seniority_timestamp: Utc::now(), cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { @@ -365,11 +342,10 @@ mod test { } } - fn indoor_wifi_coverage(owner: &str, hex: u64, signal_level: SignalLevel) -> CoverageObject { - let owner: PublicKeyBinary = owner.parse().expect("failed owner parse"); + fn indoor_wifi_coverage(owner: &[u8], hex: u64, signal_level: SignalLevel) -> CoverageObject { CoverageObject { indoor: true, - hotspot_key: owner, + hotspot_key: owner.to_vec(), seniority_timestamp: Utc::now(), cbsd_id: None, coverage: vec![UnrankedCoverage { @@ -382,12 +358,9 @@ mod test { } fn outdoor_cbrs_coverage(cbsd_id: &str, hex: u64, signal_power: i32) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: false, - hotspot_key: owner, + hotspot_key: vec![0, 0], seniority_timestamp: Utc::now(), cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { @@ -399,11 +372,10 @@ mod test { } } - fn outdoor_wifi_coverage(owner: &str, hex: u64, signal_power: i32) -> CoverageObject { - let owner: PublicKeyBinary = owner.parse().expect("failed owner parse"); + fn outdoor_wifi_coverage(owner: &[u8], hex: u64, signal_power: i32) -> CoverageObject { CoverageObject { indoor: false, - hotspot_key: owner, + hotspot_key: owner.to_vec(), seniority_timestamp: Utc::now(), cbsd_id: None, coverage: vec![UnrankedCoverage { diff --git a/coverage_map/src/outdoor.rs b/coverage_map/src/outdoor.rs index 8105cf4c4..28c3a7e1a 100644 --- a/coverage_map/src/outdoor.rs +++ b/coverage_map/src/outdoor.rs @@ -4,7 +4,6 @@ use std::{ }; use chrono::{DateTime, Utc}; -use helium_crypto::PublicKeyBinary; use hex_assignments::assignment::HexAssignments; use hextree::Cell; @@ -15,7 +14,7 @@ pub type OutdoorCellTree = HashMap>; #[derive(Eq, Debug, Clone)] pub struct OutdoorCoverageLevel { - hotspot_key: PublicKeyBinary, + hotspot_key: Vec, cbsd_id: Option, seniority_timestamp: DateTime, signal_power: i32, @@ -62,7 +61,7 @@ pub fn insert_outdoor_coverage_object( pub fn insert_outdoor_coverage( outdoor: &mut OutdoorCellTree, - hotspot: &PublicKeyBinary, + hotspot: &[u8], cbsd_id: &Option, seniority_timestamp: DateTime, hex_coverage: UnrankedCoverage, @@ -71,7 +70,7 @@ pub fn insert_outdoor_coverage( .entry(hex_coverage.location) .or_default() .push(OutdoorCoverageLevel { - hotspot_key: hotspot.clone(), + hotspot_key: hotspot.to_vec(), cbsd_id: cbsd_id.clone(), seniority_timestamp, signal_level: hex_coverage.signal_level, @@ -171,12 +170,9 @@ mod test { signal_power: i32, seniority_timestamp: DateTime, ) -> CoverageObject { - let owner: PublicKeyBinary = "112NqN2WWMwtK29PMzRby62fDydBJfsCLkCAf392stdok48ovNT6" - .parse() - .expect("failed owner parse"); CoverageObject { indoor: false, - hotspot_key: owner, + hotspot_key: vec![0, 0], seniority_timestamp, cbsd_id: Some(cbsd_id.to_string()), coverage: vec![UnrankedCoverage { From 530cb5943a4e75f5a52fc62d85cbf07e75ea2748 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Thu, 6 Jun 2024 12:19:12 -0400 Subject: [PATCH 2/2] Remove more deps --- Cargo.lock | 3 --- coverage_map/Cargo.toml | 3 --- 2 files changed, 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e987f0ed..02df28a2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2126,11 +2126,8 @@ name = "coverage-map" version = "0.1.0" dependencies = [ "chrono", - "h3o", - "helium-proto", "hex-assignments", "hextree", - "uuid", ] [[package]] diff --git a/coverage_map/Cargo.toml b/coverage_map/Cargo.toml index c9716d26f..877eebd9c 100644 --- a/coverage_map/Cargo.toml +++ b/coverage_map/Cargo.toml @@ -9,8 +9,5 @@ edition.workspace = true [dependencies] chrono = { workspace = true } -h3o = { workspace = true } -helium-proto = { workspace = true } hex-assignments = { path = "../hex_assignments" } hextree = { workspace = true } -uuid = { workspace = true }