-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change coverage map to treat hotspot_key as bytes rather than a PublicKeyBinary #825
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PublicKeyBinary, Vec<RankedCoverage>>, | ||
wifi_hotspots: HashMap<Vec<u8>, Vec<RankedCoverage>>, | ||
cbrs_radios: HashMap<String, Vec<RankedCoverage>>, | ||
} | ||
|
||
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<u8>, | ||
pub cbsd_id: Option<String>, | ||
pub seniority_timestamp: DateTime<Utc>, | ||
pub coverage: Vec<UnrankedCoverage>, | ||
|
@@ -168,7 +167,7 @@ pub struct UnrankedCoverage { | |
pub struct RankedCoverage { | ||
pub hex: Cell, | ||
pub rank: usize, | ||
pub hotspot_key: PublicKeyBinary, | ||
pub hotspot_key: Vec<u8>, | ||
pub cbsd_id: Option<String>, | ||
pub assignments: HexAssignments, | ||
pub boosted: Option<NonZeroU32>, | ||
|
@@ -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], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not very important, but these don't even need to be length 2. They could just be |
||
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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h30
,helium-proto
, anduuid
are also candidates for removal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!, removed 530cb59