Skip to content

Commit

Permalink
update reward manifest internal struct with latest fields. add cli du…
Browse files Browse the repository at this point in the history
…mp helpers
  • Loading branch information
andymck committed Nov 28, 2024
1 parent 17de4d6 commit 23e7e32
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
43 changes: 33 additions & 10 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ use helium_proto::{
services::{
packet_verifier::ValidDataTransferSession as ValidDataTransferSessionProto,
poc_lora::{
iot_reward_share::Reward as IotReward, IotRewardShare as IotRewardShareProto,
LoraBeaconIngestReportV1, LoraInvalidWitnessReportV1, LoraPocV1,
LoraWitnessIngestReportV1,
},
poc_mobile::{
mobile_reward_share::Reward, CellHeartbeatIngestReportV1, CellHeartbeatReqV1,
CoverageObjectV1, Heartbeat, InvalidDataTransferIngestReportV1, MobileRewardShare,
OracleBoostingReportV1, RadioRewardShare, SpeedtestAvg, SpeedtestIngestReportV1,
SpeedtestReqV1, VerifiedInvalidatedRadioThresholdIngestReportV1,
VerifiedRadioThresholdIngestReportV1,
mobile_reward_share::Reward as MobileReward, CellHeartbeatIngestReportV1,
CellHeartbeatReqV1, CoverageObjectV1, Heartbeat, InvalidDataTransferIngestReportV1,
MobileRewardShare, OracleBoostingReportV1, RadioRewardShare, SpeedtestAvg,
SpeedtestIngestReportV1, SpeedtestReqV1,
VerifiedInvalidatedRadioThresholdIngestReportV1, VerifiedRadioThresholdIngestReportV1,
},
router::PacketRouterPacketReportV1,
},
Expand Down Expand Up @@ -242,29 +243,51 @@ impl Cmd {
"validity": heartbeat.validity,
}))?;
}
FileType::IotRewardShare => {
let reward = IotRewardShareProto::decode(msg)?;
match reward.reward {
Some(IotReward::GatewayReward(reward)) => print_json(&json!({
"type": "gateway_reward",
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"dc_transfer_amount": reward.dc_transfer_amount,
"beacon_amount": reward.beacon_amount,
"witness_amount": reward.witness_amount,
}))?,
Some(IotReward::OperationalReward(reward)) => print_json(&json!({
"type": "operational_reward",
"amount": reward.amount,
}))?,
Some(IotReward::UnallocatedReward(reward)) => print_json(&json!({
"type": "unallocated_reward",
"unallocated_reward_type": reward.reward_type,
"amount": reward.amount,
}))?,
_ => (),
}
}
FileType::MobileRewardShare => {
let reward = MobileRewardShare::decode(msg)?;
match reward.reward {
Some(Reward::GatewayReward(reward)) => print_json(&json!({
Some(MobileReward::GatewayReward(reward)) => print_json(&json!({
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"dc_transfer_reward": reward.dc_transfer_reward,
}))?,
Some(Reward::RadioReward(reward)) => print_json(&json!({
Some(MobileReward::RadioReward(reward)) => print_json(&json!({
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"cbsd_id": reward.cbsd_id,
"poc_reward": reward.poc_reward,
"boosted_hexes": reward.boosted_hexes,
}))?,
Some(Reward::SubscriberReward(reward)) => print_json(&json!({
Some(MobileReward::SubscriberReward(reward)) => print_json(&json!({
"subscriber_id": reward.subscriber_id,
"discovery_location_amount": reward.discovery_location_amount,
"verification_mapping_amount": reward.verification_mapping_amount,
}))?,
Some(Reward::ServiceProviderReward(reward)) => print_json(&json!({
Some(MobileReward::ServiceProviderReward(reward)) => print_json(&json!({
"service_provider": reward.service_provider_id,
"amount": reward.amount,
}))?,
Some(Reward::UnallocatedReward(reward)) => print_json(&json!({
Some(MobileReward::UnallocatedReward(reward)) => print_json(&json!({
"unallocated_reward_type": reward.reward_type,
"amount": reward.amount,
}))?,
Expand Down
4 changes: 4 additions & 0 deletions file_store/src/reward_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub struct RewardManifest {
pub start_timestamp: DateTime<Utc>,
pub end_timestamp: DateTime<Utc>,
pub reward_data: Option<RewardData>,
pub epoch: u64,
pub price: u64,
}

#[derive(Clone, Debug, Serialize)]
Expand Down Expand Up @@ -47,6 +49,8 @@ impl TryFrom<proto::RewardManifest> for RewardManifest {
.ok_or(Error::Decode(DecodeError::InvalidTimestamp(
value.end_timestamp,
)))?,
epoch: value.epoch,
price: value.price,
reward_data: match value.reward_data {
Some(proto::reward_manifest::RewardData::MobileRewardData(reward_data)) => {
Some(RewardData::MobileRewardData {
Expand Down

0 comments on commit 23e7e32

Please sign in to comment.