-
Notifications
You must be signed in to change notification settings - Fork 26
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
Remove INITIALIZE and MARK_AGGREGATED from ReportsProcessed #415
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ use prio::{ | |
}, | ||
}; | ||
use rand::prelude::*; | ||
use replace_with::replace_with_or_abort; | ||
use serde::{Deserialize, Serialize, Serializer}; | ||
use std::{ | ||
borrow::Cow, | ||
|
@@ -185,6 +186,20 @@ impl<'req> EarlyReportStateConsumed<'req> { | |
input_share: input_share.payload, | ||
}) | ||
} | ||
|
||
/// Convert this EarlyReportStateConsumed into a rejected [EarlyReportStateInitialized] using | ||
/// `failure` as the reason. If this is already a rejected report, the passed in `failure` | ||
/// value overwrites the previous one. | ||
pub fn into_initialized_rejected_due_to( | ||
self, | ||
failure: TransitionFailure, | ||
) -> EarlyReportStateInitialized<'req> { | ||
let metadata = match self { | ||
Self::Ready { metadata, .. } => metadata, | ||
Self::Rejected { metadata, .. } => metadata, | ||
}; | ||
EarlyReportStateInitialized::Rejected { metadata, failure } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If My gut feeling is we probably don't want to override the failure reason, but I could be wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should override, principle of least surprise, if I pass a parameter I expect it to be used |
||
} | ||
} | ||
|
||
impl EarlyReportState for EarlyReportStateConsumed<'_> { | ||
|
@@ -307,6 +322,18 @@ impl<'req> EarlyReportStateInitialized<'req> { | |
}; | ||
Ok(early_report_state_initialized) | ||
} | ||
|
||
/// Turn this report into a rejected report using `failure` as the reason for it's rejection. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here again: Just want to double check that overwriting the failure reason in case it was already rejected is intended. |
||
pub fn reject_due_to(&mut self, failure: TransitionFailure) { | ||
// this never aborts because the closure never panics | ||
replace_with_or_abort(self, |self_| { | ||
let metadata = match self_ { | ||
Self::Rejected { metadata, .. } => metadata, | ||
Self::Ready { metadata, .. } => metadata, | ||
}; | ||
Self::Rejected { metadata, failure } | ||
}) | ||
} | ||
} | ||
|
||
impl EarlyReportState for EarlyReportStateInitialized<'_> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docucomment.