pub struct BatchProofResponse {
pub batch_id: Uuid,
pub accepted_count: usize,
pub rejected_count: usize,
pub total_reward_points: Points,
pub results: Vec<ProofResult>,
}Expand description
Response to batch proof submission.
Fields§
§batch_id: UuidBatch ID that was processed.
accepted_count: usizeNumber of proofs accepted.
rejected_count: usizeNumber of proofs rejected.
total_reward_points: PointsTotal reward points for accepted proofs.
results: Vec<ProofResult>Individual results per proof.
Implementations§
Source§impl BatchProofResponse
impl BatchProofResponse
Sourcepub fn new(batch_id: Uuid) -> Self
pub fn new(batch_id: Uuid) -> Self
Create a new batch response.
§Example
use chie_shared::types::batch::{BatchProofResponse, ProofResult};
use uuid::Uuid;
let batch_id = Uuid::new_v4();
let mut response = BatchProofResponse::new(batch_id);
// Add results
response.results.push(ProofResult::accepted(0, Uuid::new_v4(), 1000));
response.results.push(ProofResult::accepted(1, Uuid::new_v4(), 1500));
response.results.push(ProofResult::rejected(2, "Invalid signature"));
response.accepted_count = 2;
response.rejected_count = 1;
response.total_reward_points = 2500;
assert_eq!(response.total_count(), 3);
assert_eq!(response.acceptance_rate(), 2.0 / 3.0);
assert!(!response.all_accepted());
assert!(!response.all_rejected());Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Get total number of proofs processed.
Sourcepub fn acceptance_rate(&self) -> f64
pub fn acceptance_rate(&self) -> f64
Get acceptance rate (0.0 to 1.0).
Sourcepub fn all_accepted(&self) -> bool
pub fn all_accepted(&self) -> bool
Check if all proofs were accepted.
Sourcepub fn all_rejected(&self) -> bool
pub fn all_rejected(&self) -> bool
Check if all proofs were rejected.
Trait Implementations§
Source§impl Clone for BatchProofResponse
impl Clone for BatchProofResponse
Source§fn clone(&self) -> BatchProofResponse
fn clone(&self) -> BatchProofResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BatchProofResponse
impl Debug for BatchProofResponse
Source§impl<'de> Deserialize<'de> for BatchProofResponse
impl<'de> Deserialize<'de> for BatchProofResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BatchProofResponse
impl RefUnwindSafe for BatchProofResponse
impl Send for BatchProofResponse
impl Sync for BatchProofResponse
impl Unpin for BatchProofResponse
impl UnwindSafe for BatchProofResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more