Skip to content

Commit

Permalink
use service provider proto string impls
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Jan 9, 2024
1 parent 7aaf177 commit 359e06a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ sqlx = {version = "0", features = [
"runtime-tokio-rustls"
]}
helium-crypto = {version = "0.8.1", features=["sqlx-postgres", "multisig"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "master", features = ["services"]}
helium-proto = {git = "https://github.com/helium/proto", branch = "andymck/sp-str-impls", features = ["services"]}
hextree = "*"
solana-client = "1.14"
solana-sdk = "1.14"
solana-program = "1.11"
spl-token = "3.5.0"
reqwest = {version = "0", default-features=false, features = ["gzip", "json", "rustls-tls"]}
beacon = { git = "https://github.com/helium/proto", branch = "master" }
beacon = { git = "https://github.com/helium/proto", branch = "andymck/sp-str-impls" }
humantime = "2"
metrics = "0"
metrics-exporter-prometheus = "0"
Expand Down
2 changes: 0 additions & 2 deletions mobile_config/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pub enum ClientError {
VerificationError(#[from] file_store::Error),
#[error("error parsing gateway location {0}")]
LocationParseError(#[from] std::num::ParseIntError),
#[error("unknown service provider")]
UnknownServiceProvider,
}

macro_rules! call_with_retry {
Expand Down
2 changes: 1 addition & 1 deletion mobile_verifier/src/data_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use futures::{
TryFutureExt,
};
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::ServiceProvider;
use helium_proto::ServiceProvider;
use rust_decimal::Decimal;
use sqlx::{PgPool, Postgres, Row, Transaction};
use std::{collections::HashMap, ops::Range, time::Instant};
Expand Down
21 changes: 7 additions & 14 deletions mobile_verifier/src/reward_shares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use crate::{
speedtests_average::{SpeedtestAverage, SpeedtestAverages},
subscriber_location::SubscriberValidatedLocations,
};
use anyhow::bail;
use chrono::{DateTime, Duration, Utc};
use file_store::traits::TimestampEncode;
use futures::{Stream, StreamExt};
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::{
ServiceProvider, UnallocatedReward, UnallocatedRewardType,
};
use helium_proto::services::{
poc_mobile as proto, poc_mobile::mobile_reward_share::Reward as ProtoReward,
};
use helium_proto::{
services::poc_mobile::{UnallocatedReward, UnallocatedRewardType},
ServiceProvider,
};
use mobile_config::client::{carrier_service_client::CarrierServiceVerifier, ClientError};
use rust_decimal::prelude::*;
use rust_decimal_macros::dec;
Expand Down Expand Up @@ -330,14 +330,7 @@ impl ServiceProviderShares {
) -> anyhow::Result<ServiceProvider> {
tracing::info!(payer, "getting entity key for service provider");
let entity_key = client.key_to_rewardable_entity(payer).await?;
Self::entity_key_to_service_provider(&entity_key)
}

fn entity_key_to_service_provider(key: &str) -> anyhow::Result<ServiceProvider> {
match key {
"Helium Mobile" => Ok(ServiceProvider::HeliumMobile),
_ => bail!("invalid service provider name"),
}
Ok(ServiceProvider::from_str(&entity_key)?)
}
}

Expand Down Expand Up @@ -604,8 +597,8 @@ mod test {
use chrono::{Duration, Utc};
use file_store::speedtest::CellSpeedtest;
use futures::stream::{self, BoxStream};
use helium_proto::services::{
poc_mobile::mobile_reward_share::Reward as MobileReward, poc_mobile::ServiceProvider,
use helium_proto::{
services::poc_mobile::mobile_reward_share::Reward as MobileReward, ServiceProvider,
};
use prost::Message;
use std::collections::HashMap;
Expand Down
14 changes: 3 additions & 11 deletions reward_index/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ use futures::{stream, StreamExt, TryStreamExt};
use helium_crypto::PublicKeyBinary;
use helium_proto::{
services::poc_lora::{iot_reward_share::Reward as IotReward, IotRewardShare},
services::poc_mobile::{
mobile_reward_share::Reward as MobileReward, MobileRewardShare, ServiceProvider,
},
Message,
services::poc_mobile::{mobile_reward_share::Reward as MobileReward, MobileRewardShare},
Message, ServiceProvider,
};
use poc_metrics::record_duration;
use sqlx::{Pool, Postgres, Transaction};
Expand Down Expand Up @@ -163,7 +161,7 @@ impl Indexer {
if let Some(sp) = ServiceProvider::from_i32(r.service_provider_id) {
Ok((
RewardKey {
key: service_provider_to_entity_key(sp)?,
key: sp.to_string(),
reward_type: RewardType::MobileServiceProvider,
},
r.amount,
Expand Down Expand Up @@ -212,9 +210,3 @@ impl Indexer {
}
}
}

fn service_provider_to_entity_key(sp: ServiceProvider) -> anyhow::Result<String> {
match sp {
ServiceProvider::HeliumMobile => Ok("Helium Mobile".to_string()),
}
}

0 comments on commit 359e06a

Please # to comment.