pub struct BatchProofSubmission {
pub proofs: Vec<BandwidthProof>,
pub batch_id: Uuid,
pub peer_id: PeerIdString,
pub timestamp_ms: i64,
}Expand description
Batch submission of bandwidth proofs.
Fields§
§proofs: Vec<BandwidthProof>List of proofs to submit.
batch_id: UuidBatch ID for tracking.
peer_id: PeerIdStringSubmitter peer ID.
timestamp_ms: i64Submission timestamp (Unix milliseconds).
Implementations§
Source§impl BatchProofSubmission
impl BatchProofSubmission
Sourcepub fn new(proofs: Vec<BandwidthProof>, peer_id: impl Into<String>) -> Self
pub fn new(proofs: Vec<BandwidthProof>, peer_id: impl Into<String>) -> Self
Create a new batch proof submission.
§Example
use chie_shared::types::batch::BatchProofSubmission;
use chie_shared::types::bandwidth::BandwidthProofBuilder;
// Create multiple bandwidth proofs
let proof1 = BandwidthProofBuilder::new()
.content_cid("bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi")
.provider_peer_id("12D3KooWProvider")
.requester_peer_id("12D3KooWRequester")
.provider_public_key(vec![1u8; 32])
.requester_public_key(vec![2u8; 32])
.provider_signature(vec![3u8; 64])
.requester_signature(vec![4u8; 64])
.challenge_nonce(vec![5u8; 32])
.chunk_hash(vec![6u8; 32])
.bytes_transferred(262_144)
.timestamps(1000, 1100)
.build()
.unwrap();
let proof2 = BandwidthProofBuilder::new()
.content_cid("bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi")
.chunk_index(1)
.provider_peer_id("12D3KooWProvider")
.requester_peer_id("12D3KooWRequester")
.provider_public_key(vec![1u8; 32])
.requester_public_key(vec![2u8; 32])
.provider_signature(vec![3u8; 64])
.requester_signature(vec![4u8; 64])
.challenge_nonce(vec![5u8; 32])
.chunk_hash(vec![6u8; 32])
.bytes_transferred(262_144)
.timestamps(1100, 1200)
.build()
.unwrap();
// Submit proofs as a batch
let batch = BatchProofSubmission::new(
vec![proof1, proof2],
"12D3KooWProvider"
);
assert_eq!(batch.proof_count(), 2);
assert_eq!(batch.total_bytes_transferred(), 524_288);
assert!(!batch.is_empty());Sourcepub fn proof_count(&self) -> usize
pub fn proof_count(&self) -> usize
Get the number of proofs in the batch.
Sourcepub fn total_bytes_transferred(&self) -> u64
pub fn total_bytes_transferred(&self) -> u64
Calculate total bytes transferred across all proofs.
Trait Implementations§
Source§impl Clone for BatchProofSubmission
impl Clone for BatchProofSubmission
Source§fn clone(&self) -> BatchProofSubmission
fn clone(&self) -> BatchProofSubmission
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 BatchProofSubmission
impl Debug for BatchProofSubmission
Source§impl<'de> Deserialize<'de> for BatchProofSubmission
impl<'de> Deserialize<'de> for BatchProofSubmission
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 BatchProofSubmission
impl RefUnwindSafe for BatchProofSubmission
impl Send for BatchProofSubmission
impl Sync for BatchProofSubmission
impl Unpin for BatchProofSubmission
impl UnwindSafe for BatchProofSubmission
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