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

enrich denied reports with denylist tagname #604

Merged
merged 1 commit into from
Aug 17, 2023
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
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.

11 changes: 8 additions & 3 deletions file_store/src/iot_invalid_poc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ use crate::{
};
use chrono::{DateTime, Utc};
use helium_proto::services::poc_lora::{
InvalidParticipantSide, InvalidReason, LoraBeaconReportReqV1, LoraInvalidBeaconReportV1,
LoraInvalidWitnessReportV1, LoraWitnessReportReqV1,
InvalidDetails, InvalidParticipantSide, InvalidReason, LoraBeaconReportReqV1,
LoraInvalidBeaconReportV1, LoraInvalidWitnessReportV1, LoraWitnessReportReqV1,
};
use serde::Serialize;

#[derive(Serialize, Clone)]
pub struct IotInvalidBeaconReport {
pub received_timestamp: DateTime<Utc>,
pub reason: InvalidReason,
pub invalid_details: Option<InvalidDetails>,
pub report: IotBeaconReport,
pub location: Option<u64>,
pub gain: i32,
Expand All @@ -26,6 +27,7 @@ pub struct IotInvalidBeaconReport {
pub struct IotInvalidWitnessReport {
pub received_timestamp: DateTime<Utc>,
pub reason: InvalidReason,
pub invalid_details: Option<InvalidDetails>,
pub report: IotWitnessReport,
pub participant_side: InvalidParticipantSide,
}
Expand Down Expand Up @@ -70,7 +72,6 @@ impl TryFrom<LoraInvalidBeaconReportV1> for IotInvalidBeaconReport {
InvalidReason::from_i32(inv_reason).ok_or_else(|| {
DecodeError::unsupported_invalid_reason("iot_invalid_beacon_report_v1", inv_reason)
})?;

Ok(Self {
received_timestamp: v.timestamp()?,
reason: invalid_reason,
Expand All @@ -81,6 +82,7 @@ impl TryFrom<LoraInvalidBeaconReportV1> for IotInvalidBeaconReport {
location: v.location.parse().ok(),
gain: v.gain,
elevation: v.elevation,
invalid_details: v.invalid_details,
})
}
}
Expand All @@ -99,6 +101,7 @@ impl From<IotInvalidBeaconReport> for LoraInvalidBeaconReportV1 {
.unwrap_or_else(String::new),
gain: v.gain,
elevation: v.elevation,
invalid_details: v.invalid_details,
}
}
}
Expand Down Expand Up @@ -129,6 +132,7 @@ impl TryFrom<LoraInvalidWitnessReportV1> for IotInvalidWitnessReport {
.report
.ok_or_else(|| Error::not_found("iot invalid witness report"))?
.try_into()?,
invalid_details: v.invalid_details,
})
}
}
Expand All @@ -142,6 +146,7 @@ impl From<IotInvalidWitnessReport> for LoraInvalidWitnessReportV1 {
reason: v.reason as i32,
report: Some(report),
participant_side: v.participant_side as i32,
invalid_details: v.invalid_details,
}
}
}
11 changes: 9 additions & 2 deletions file_store/src/iot_valid_poc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use chrono::{DateTime, Utc};
use helium_proto::services::poc_lora::{
InvalidParticipantSide, InvalidReason, LoraBeaconReportReqV1, LoraPocV1,
InvalidDetails, InvalidParticipantSide, InvalidReason, LoraBeaconReportReqV1, LoraPocV1,
LoraValidBeaconReportV1, LoraVerifiedWitnessReportV1, LoraWitnessReportReqV1,
VerificationStatus,
};
Expand Down Expand Up @@ -51,6 +51,7 @@ pub struct IotVerifiedWitnessReport {
pub reward_unit: Decimal,
pub invalid_reason: InvalidReason,
pub participant_side: InvalidParticipantSide,
pub invalid_details: Option<InvalidDetails>,
}

#[derive(Serialize, Clone, Debug)]
Expand Down Expand Up @@ -186,7 +187,6 @@ impl TryFrom<LoraVerifiedWitnessReportV1> for IotVerifiedWitnessReport {
v.participant_side,
)
})?;

Ok(Self {
received_timestamp,
status,
Expand All @@ -201,6 +201,7 @@ impl TryFrom<LoraVerifiedWitnessReportV1> for IotVerifiedWitnessReport {
reward_unit: Decimal::new(v.reward_unit as i64, SCALING_PRECISION),
invalid_reason,
participant_side,
invalid_details: v.invalid_details,
})
}
}
Expand All @@ -223,6 +224,7 @@ impl From<IotVerifiedWitnessReport> for LoraVerifiedWitnessReportV1 {
reward_unit: (v.reward_unit * SCALE_MULTIPLIER).to_u32().unwrap_or(0),
invalid_reason: v.invalid_reason as i32,
participant_side: v.participant_side as i32,
invalid_details: v.invalid_details,
}
}
}
Expand All @@ -249,10 +251,14 @@ impl IotVerifiedWitnessReport {
// valid, non-failed witnesses for the final validated poc report
reward_unit: Decimal::ZERO,
participant_side: InvalidParticipantSide::SideNone,
invalid_details: None,
}
}

#[allow(clippy::too_many_arguments)]
pub fn invalid(
invalid_reason: InvalidReason,
invalid_details: Option<InvalidDetails>,
report: &IotWitnessReport,
received_timestamp: DateTime<Utc>,
location: Option<u64>,
Expand All @@ -264,6 +270,7 @@ impl IotVerifiedWitnessReport {
received_timestamp,
status: VerificationStatus::Invalid,
invalid_reason,
invalid_details,
report: report.clone(),
location,
gain,
Expand Down
Loading
Loading