From f45d5c80604227592f1ce746ad35df7209aa8af9 Mon Sep 17 00:00:00 2001 From: Andrew McKenzie Date: Mon, 2 Oct 2023 13:53:08 +0100 Subject: [PATCH] remove unused setting support --- mobile_verifier/src/cli/reward_from_db.rs | 3 +- mobile_verifier/src/cli/server.rs | 1 - mobile_verifier/src/heartbeats/mod.rs | 5 +- mobile_verifier/src/reward_shares.rs | 59 +++++++++-------------- mobile_verifier/src/rewarder.rs | 6 +-- mobile_verifier/src/settings.rs | 6 --- 6 files changed, 26 insertions(+), 54 deletions(-) diff --git a/mobile_verifier/src/cli/reward_from_db.rs b/mobile_verifier/src/cli/reward_from_db.rs index 0d69e7cbb..ea94c4191 100644 --- a/mobile_verifier/src/cli/reward_from_db.rs +++ b/mobile_verifier/src/cli/reward_from_db.rs @@ -39,8 +39,7 @@ impl Cmd { HeartbeatReward::validated(&pool, &epoch, settings.max_asserted_distance_deviation); let speedtest_averages = SpeedtestAverages::aggregate_epoch_averages(epoch.end, &pool).await?; - let reward_shares = - PocShares::aggregate(heartbeats, &speedtest_averages, settings.reward_wifi_hbs).await?; + let reward_shares = PocShares::aggregate(heartbeats, &speedtest_averages).await?; let mut total_rewards = 0_u64; let mut owner_rewards = HashMap::<_, u64>::new(); diff --git a/mobile_verifier/src/cli/server.rs b/mobile_verifier/src/cli/server.rs index 585fdda38..d8455172b 100644 --- a/mobile_verifier/src/cli/server.rs +++ b/mobile_verifier/src/cli/server.rs @@ -173,7 +173,6 @@ impl Cmd { mobile_rewards, reward_manifests, price_tracker, - settings.reward_wifi_hbs, settings.max_asserted_distance_deviation, ); diff --git a/mobile_verifier/src/heartbeats/mod.rs b/mobile_verifier/src/heartbeats/mod.rs index 7cb4ab7c0..2cbb9cb1c 100644 --- a/mobile_verifier/src/heartbeats/mod.rs +++ b/mobile_verifier/src/heartbeats/mod.rs @@ -127,10 +127,7 @@ impl HeartbeatReward { } } - pub fn reward_weight(&self, reward_wifi_hbs: bool) -> Decimal { - if !reward_wifi_hbs && self.cell_type.to_label() == CellTypeLabel::Wifi { - return Decimal::ZERO; - } + pub fn reward_weight(&self) -> Decimal { self.reward_weight } diff --git a/mobile_verifier/src/reward_shares.rs b/mobile_verifier/src/reward_shares.rs index 821686a59..d3dd65fd6 100644 --- a/mobile_verifier/src/reward_shares.rs +++ b/mobile_verifier/src/reward_shares.rs @@ -221,7 +221,6 @@ impl PocShares { pub async fn aggregate( heartbeat_rewards: impl Stream>, speedtest_averages: &SpeedtestAverages, - reward_wifi_hbs: bool, ) -> anyhow::Result { let mut poc_shares = Self::default(); let mut heartbeat_rewards = std::pin::pin!(heartbeat_rewards); @@ -236,7 +235,7 @@ impl PocShares { .or_default() .radio_shares .entry(heartbeat_reward.cbsd_id.clone()) - .or_default() += heartbeat_reward.reward_weight(reward_wifi_hbs) * speedmultiplier; + .or_default() += heartbeat_reward.reward_weight() * speedmultiplier; } Ok(poc_shares) } @@ -704,13 +703,10 @@ mod test { averages.insert(g5.clone(), g5_average); let speedtest_avgs = SpeedtestAverages { averages }; - let rewards = PocShares::aggregate( - stream::iter(heartbeat_rewards).map(Ok), - &speedtest_avgs, - true, - ) - .await - .unwrap(); + let rewards = + PocShares::aggregate(stream::iter(heartbeat_rewards).map(Ok), &speedtest_avgs) + .await + .unwrap(); let gw1_shares = rewards .hotspot_shares @@ -1033,15 +1029,12 @@ mod test { let mut owner_rewards = HashMap::::new(); let duration = Duration::hours(1); let epoch = (now - duration)..now; - for mobile_reward in PocShares::aggregate( - stream::iter(heartbeat_rewards).map(Ok), - &speedtest_avgs, - true, - ) - .await - .unwrap() - .into_rewards(Decimal::ZERO, &epoch) - .unwrap() + for mobile_reward in + PocShares::aggregate(stream::iter(heartbeat_rewards).map(Ok), &speedtest_avgs) + .await + .unwrap() + .into_rewards(Decimal::ZERO, &epoch) + .unwrap() { let radio_reward = match mobile_reward.reward { Some(proto::mobile_reward_share::Reward::RadioReward(radio_reward)) => radio_reward, @@ -1196,15 +1189,12 @@ mod test { let mut owner_rewards = HashMap::::new(); let duration = Duration::hours(1); let epoch = (now - duration)..now; - for mobile_reward in PocShares::aggregate( - stream::iter(heartbeat_rewards).map(Ok), - &speedtest_avgs, - true, - ) - .await - .unwrap() - .into_rewards(Decimal::ZERO, &epoch) - .unwrap() + for mobile_reward in + PocShares::aggregate(stream::iter(heartbeat_rewards).map(Ok), &speedtest_avgs) + .await + .unwrap() + .into_rewards(Decimal::ZERO, &epoch) + .unwrap() { let radio_reward = match mobile_reward.reward { Some(proto::mobile_reward_share::Reward::RadioReward(radio_reward)) => radio_reward, @@ -1315,15 +1305,12 @@ mod test { let mut owner_rewards = HashMap::::new(); let duration = Duration::hours(1); let epoch = (now - duration)..now; - for mobile_reward in PocShares::aggregate( - stream::iter(heartbeat_rewards).map(Ok), - &speedtest_avgs, - true, - ) - .await - .unwrap() - .into_rewards(Decimal::ZERO, &epoch) - .unwrap() + for mobile_reward in + PocShares::aggregate(stream::iter(heartbeat_rewards).map(Ok), &speedtest_avgs) + .await + .unwrap() + .into_rewards(Decimal::ZERO, &epoch) + .unwrap() { let radio_reward = match mobile_reward.reward { Some(proto::mobile_reward_share::Reward::RadioReward(radio_reward)) => radio_reward, diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index 9a4d4a50f..8613ac1c3 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -28,7 +28,6 @@ pub struct Rewarder { mobile_rewards: FileSinkClient, reward_manifests: FileSinkClient, price_tracker: PriceTracker, - reward_wifi_hbs: bool, max_distance_to_asserted: u32, } @@ -41,7 +40,6 @@ impl Rewarder { mobile_rewards: FileSinkClient, reward_manifests: FileSinkClient, price_tracker: PriceTracker, - reward_wifi_hbs: bool, max_distance_to_asserted: u32, ) -> Self { Self { @@ -51,7 +49,6 @@ impl Rewarder { mobile_rewards, reward_manifests, price_tracker, - reward_wifi_hbs, max_distance_to_asserted, } } @@ -149,8 +146,7 @@ impl Rewarder { HeartbeatReward::validated(&self.pool, reward_period, self.max_distance_to_asserted); let speedtest_averages = SpeedtestAverages::aggregate_epoch_averages(reward_period.end, &self.pool).await?; - let poc_rewards = - PocShares::aggregate(heartbeats, &speedtest_averages, self.reward_wifi_hbs).await?; + let poc_rewards = PocShares::aggregate(heartbeats, &speedtest_averages).await?; let mobile_price = self .price_tracker .price(&helium_proto::BlockchainTokenTypeV1::Mobile) diff --git a/mobile_verifier/src/settings.rs b/mobile_verifier/src/settings.rs index 1d69a5d49..d61dbba45 100644 --- a/mobile_verifier/src/settings.rs +++ b/mobile_verifier/src/settings.rs @@ -25,8 +25,6 @@ pub struct Settings { pub config_client: mobile_config::ClientSettings, #[serde(default = "default_start_after")] pub start_after: u64, - #[serde(default = "default_reward_wifi_hbs")] - pub reward_wifi_hbs: bool, // Max distance in meters between the asserted location of a WIFI hotspot // and the lat/lng defined in a heartbeat // beyond which its location weight will be reduced @@ -42,10 +40,6 @@ pub fn default_log() -> String { "mobile_verifier=debug,poc_store=info".to_string() } -pub fn default_reward_wifi_hbs() -> bool { - false -} - pub fn default_start_after() -> u64 { 0 }