BatchProofSubmission

Struct BatchProofSubmission 

Source
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: Uuid

Batch ID for tracking.

§peer_id: PeerIdString

Submitter peer ID.

§timestamp_ms: i64

Submission timestamp (Unix milliseconds).

Implementations§

Source§

impl BatchProofSubmission

Source

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());
Source

pub fn proof_count(&self) -> usize

Get the number of proofs in the batch.

Source

pub fn is_empty(&self) -> bool

Check if batch is empty.

Source

pub fn total_bytes_transferred(&self) -> u64

Calculate total bytes transferred across all proofs.

Trait Implementations§

Source§

impl Clone for BatchProofSubmission

Source§

fn clone(&self) -> BatchProofSubmission

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatchProofSubmission

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BatchProofSubmission

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BatchProofSubmission

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,