Output mobile rewards to iceberg tables#1163
Merged
Merged
Conversation
macpie
approved these changes
Mar 26, 2026
| #[derive(Debug, Clone, Trino, Serialize, Deserialize, PartialEq)] | ||
| pub struct IcebergGatewayReward { | ||
| hotspot_key: String, | ||
| dc_transfer_reward: i64, |
Contributor
There was a problem hiding this comment.
Can we use u64 for all the fields we know will never be negative? Also matches the proto already.
| fn from(share: &MobileRewardShare) -> Self { | ||
| let reward = match &share.reward { | ||
| Some(ProtoReward::GatewayReward(r)) => r, | ||
| other => panic!("expected GatewayReward, got {other:?}"), |
Contributor
There was a problem hiding this comment.
We are panicking now?
188cdb5 to
5c267f8
Compare
* Implement Copy for DeviceType DeviceType is a simple enum, which makes it a prime candidate for implementing copy so we don’t have to worry about managing references to it. * Move ToProtoDecimal up to lib, add companion FromProtoDecimal This type is useful in tests and in the main rewarder logic when we’re making protos for mobile reward shares. Also adding a companion `FromProtoDecimal` to try and keep our to/from different Decimal types all in one place. * Refactor Iceberg mappings In rewarder.rs, I changed the `.into_rewards()` calls to return an interator of the type of reward rather than a `MobileRewardShare`. This allows us to not have to worry about unwrapping options for types that we know exist. The `panic!()`s were removed becuase we no longer have to unwrap the reward type from the `MobileRewardShare`, and we have a bit better type checking on our conversions. This comes in extra handy when needing to map them into iceberg table types. And allows us to pass in the epoch periods as `DateTime<Utc>` rather than extracting them back out from `u64` timestamps into `DateTime<FixedOffset>`. I also went through and removed all the `i64` uses for fields that can never carry negative numbers.
Thanks Clippy, you’re the best
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
mobile reward data in mobile_verifier/src/iceberg/:
Also adds the RewardWriters/RewardTransactions orchestration in mod.rs, wires them into rewarder.rs to write
reward data during reward calculation, and initializes them in cli/server.rs. Test files are updated to pass
the new writer through.
2. Rename reward tables (7711ee0) — Moves the 5 reward tables from the poc namespace to rewards, and renames
them: radio_rewards → proof_of_coverage, radio_reward_covered_hexes → covered_hexes, gateway_rewards →
data_transfer, service_provider_rewards → service_provider, unallocated_rewards → unallocated.
3. Refactor variable name (188cdb5) — Minor variable rename cleanup.