Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verified data transfer #872

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 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 @@ -71,10 +71,10 @@ helium-lib = { git = "https://github.com/helium/helium-wallet-rs.git", branch =
hextree = { git = "https://github.com/jaykickliter/HexTree", branch = "main", features = [
"disktree",
] }
helium-proto = { git = "https://github.com/helium/proto", branch = "master", features = [
helium-proto = { git = "https://github.com/helium/proto", branch = "mj/verified-data-transfer", features = [
"services",
] }
beacon = { git = "https://github.com/helium/proto", branch = "master" }
beacon = { git = "https://github.com/helium/proto", branch = "mj/verified-data-transfer" }
solana-client = "1.18"
solana-sdk = "1.18"
solana-program = "1.18"
Expand Down
4 changes: 4 additions & 0 deletions file_store/src/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub const DATA_TRANSFER_SESSION_INGEST_REPORT: &str = "data_transfer_session_ing
pub const INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT: &str =
"invalid_data_transfer_session_ingest_report";
pub const VALID_DATA_TRANSFER_SESSION: &str = "valid_data_transfer_session";
pub const VERIFIED_DATA_TRANSFER_SESSION: &str = "verified_data_transfer_session";
pub const PRICE_REPORT: &str = "price_report";
pub const MOBILE_REWARD_SHARE: &str = "mobile_reward_share";
pub const MAPPER_MSG: &str = "mapper_msg";
Expand Down Expand Up @@ -196,6 +197,7 @@ pub enum FileType {
DataTransferSessionIngestReport,
InvalidDataTransferSessionIngestReport,
ValidDataTransferSession,
VerifiedDataTransferSession,
PriceReport,
MobileRewardShare,
SubscriberLocationReq,
Expand Down Expand Up @@ -276,6 +278,7 @@ impl fmt::Display for FileType {
INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT
}
Self::ValidDataTransferSession => VALID_DATA_TRANSFER_SESSION,
Self::VerifiedDataTransferSession => VERIFIED_DATA_TRANSFER_SESSION,
Self::PriceReport => PRICE_REPORT,
Self::MobileRewardShare => MOBILE_REWARD_SHARE,
Self::MapperMsg => MAPPER_MSG,
Expand Down Expand Up @@ -353,6 +356,7 @@ impl FileType {
INVALID_DATA_TRANSFER_SESSION_INGEST_REPORT
}
Self::ValidDataTransferSession => VALID_DATA_TRANSFER_SESSION,
Self::VerifiedDataTransferSession => VERIFIED_DATA_TRANSFER_SESSION,
Self::PriceReport => PRICE_REPORT,
Self::MobileRewardShare => MOBILE_REWARD_SHARE,
Self::MapperMsg => MAPPER_MSG,
Expand Down
30 changes: 28 additions & 2 deletions file_store/src/mobile_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use chrono::{DateTime, Utc};
use helium_crypto::PublicKeyBinary;
use helium_proto::services::poc_mobile::{
invalid_data_transfer_ingest_report_v1::DataTransferIngestReportStatus,
DataTransferEvent as DataTransferEventProto, DataTransferRadioAccessTechnology,
DataTransferSessionIngestReportV1, DataTransferSessionReqV1, InvalidDataTransferIngestReportV1,
verified_data_transfer_ingest_report_v1, DataTransferEvent as DataTransferEventProto,
DataTransferRadioAccessTechnology, DataTransferSessionIngestReportV1, DataTransferSessionReqV1,
InvalidDataTransferIngestReportV1, VerifiedDataTransferIngestReportV1,
};

use serde::Serialize;
Expand Down Expand Up @@ -112,6 +113,31 @@ impl From<InvalidDataTransferIngestReport> for InvalidDataTransferIngestReportV1
}
}

#[derive(Serialize, Clone, Debug)]
pub struct VerifiedDataTransferIngestReport {
pub report: DataTransferSessionIngestReport,
pub status: verified_data_transfer_ingest_report_v1::ReportStatus,
pub timestamp: DateTime<Utc>,
}

impl MsgTimestamp<u64> for VerifiedDataTransferIngestReport {
fn timestamp(&self) -> u64 {
self.timestamp.encode_timestamp_millis()
}
}

impl From<VerifiedDataTransferIngestReport> for VerifiedDataTransferIngestReportV1 {
fn from(v: VerifiedDataTransferIngestReport) -> Self {
let timestamp = v.timestamp();
let report: DataTransferSessionIngestReportV1 = v.report.into();
Self {
report: Some(report),
status: v.status as i32,
timestamp,
}
}
}

#[derive(Serialize, Clone, Debug)]
pub struct DataTransferEvent {
pub pub_key: PublicKeyBinary,
Expand Down
5 changes: 5 additions & 0 deletions file_store/src/traits/file_sink_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ impl_file_sink!(
FileType::InvalidDataTransferSessionIngestReport.to_str(),
"invalid_data_transfer_session"
);
impl_file_sink!(
poc_mobile::VerifiedDataTransferIngestReportV1,
FileType::VerifiedDataTransferSession.to_str(),
"verified_data_transfer_session"
);
impl_file_sink!(
poc_mobile::InvalidatedRadioThresholdIngestReportV1,
FileType::InvalidatedRadioThresholdIngestReport.to_str(),
Expand Down
Loading