RepairingChunkSet

Struct RepairingChunkSet 

Source
pub struct RepairingChunkSet { /* private fields */ }
Expand description

A structure designed to help incrementally reconstruct the original data of a ChunkSet by collecting enough erasure-coded chunks, verifying their integrity, and performing RLNC decoding.

Implementations§

Source§

impl RepairingChunkSet

Source

pub fn new(chunkset_id: usize, commitment: Hash) -> Self

Creates a new RepairingChunkSet instance.

§Arguments
  • chunkset_id - The ID of the chunkset being repaired.
  • commitment - The expected Merkle root commitment of the chunkset, used for validating chunk inclusion in chunkset.
§Returns

A new RepairingChunkSet instance.

Source

pub fn add_chunk( &mut self, chunk: &ProofCarryingChunk, ) -> Result<(), DecdsError>

Adds a ProofCarryingChunk to the RepairingChunkSet after validating its Merkle proof. The chunk’s inclusion proof in this chunkset is verified against the commitment stored in RepairingChunkSet.

§Arguments
  • chunk - The ProofCarryingChunk to add.
§Returns

Returns a Result which is:

  • Ok(()) if the chunk is successfully added and validated.
  • Err(DecdsError::InvalidProofInChunk) if the chunk’s inclusion proof is invalid for this chunkset.
  • Err(DecdsError::InvalidChunkMetadata) if the chunk’s chunkset_id does not match this RepairingChunkSet.
  • Err(DecdsError::ChunkDecodingFailed) if the underlying RLNC decoding operation fails.
Source

pub fn add_chunk_unvalidated( &mut self, chunk: &ProofCarryingChunk, ) -> Result<(), DecdsError>

Adds a ProofCarryingChunk to the RepairingChunkSet without validating its Merkle proof. This method is intended for use when proof validation has already occurred.

§Arguments
  • chunk - The ProofCarryingChunk to add.
§Returns

Returns a Result which is:

  • Ok(()) if the chunk is successfully added.
  • Err(DecdsError::InvalidChunkMetadata) if the chunk’s chunkset_id does not match this RepairingChunkSet.
  • Err(DecdsError::ChunksetReadyToRepair) if the chunkset is ready to repair, no more chunks are required. Just call repair.
  • Err(DecdsError::ChunkDecodingFailed) if the underlying RLNC decoding operation fails.
Source

pub fn is_ready_to_repair(&self) -> bool

Checks if enough useful erasure-coded chunks have been collected to repair the original data for this chunkset.

Source

pub fn repair(self) -> Result<Vec<u8>, DecdsError>

Repairs the original data of the chunkset if enough chunks have been collected. This consumes the RepairingChunkSet as the decoding process is final.

§Returns

Returns a Result which is:

  • Ok(Vec<u8>) containing the repaired original data if successful.
  • Err(DecdsError::ChunksetNotYetReadyToRepair) if not enough chunks have been added yet.
  • Err(DecdsError::ChunksetRepairingFailed) if an error occurs during the RLNC decoding process.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V