Skip to content

Commit

Permalink
remove unused setting support
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Oct 2, 2023
1 parent 60f2542 commit f45d5c8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 54 deletions.
3 changes: 1 addition & 2 deletions mobile_verifier/src/cli/reward_from_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion mobile_verifier/src/cli/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ impl Cmd {
mobile_rewards,
reward_manifests,
price_tracker,
settings.reward_wifi_hbs,
settings.max_asserted_distance_deviation,
);

Expand Down
5 changes: 1 addition & 4 deletions mobile_verifier/src/heartbeats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
59 changes: 23 additions & 36 deletions mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ impl PocShares {
pub async fn aggregate(
heartbeat_rewards: impl Stream<Item = Result<HeartbeatReward, sqlx::Error>>,
speedtest_averages: &SpeedtestAverages,
reward_wifi_hbs: bool,
) -> anyhow::Result<Self> {
let mut poc_shares = Self::default();
let mut heartbeat_rewards = std::pin::pin!(heartbeat_rewards);
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1033,15 +1029,12 @@ mod test {
let mut owner_rewards = HashMap::<PublicKeyBinary, u64>::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,
Expand Down Expand Up @@ -1196,15 +1189,12 @@ mod test {
let mut owner_rewards = HashMap::<PublicKeyBinary, u64>::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,
Expand Down Expand Up @@ -1315,15 +1305,12 @@ mod test {
let mut owner_rewards = HashMap::<PublicKeyBinary, u64>::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,
Expand Down
6 changes: 1 addition & 5 deletions mobile_verifier/src/rewarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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 {
Expand All @@ -51,7 +49,6 @@ impl Rewarder {
mobile_rewards,
reward_manifests,
price_tracker,
reward_wifi_hbs,
max_distance_to_asserted,
}
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions mobile_verifier/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit f45d5c8

Please sign in to comment.