pub struct RepairingBlob { /* private fields */ }Expand description
Represents a blob that is in the process of being incrementally repaired or reconstructed
from received ProofCarryingChunks.
Implementations§
Source§impl RepairingBlob
impl RepairingBlob
Sourcepub fn new(header: BlobHeader) -> Self
pub fn new(header: BlobHeader) -> Self
Creates a new RepairingBlob instance from a BlobHeader.
This initializes an empty RepairingChunkSet for each chunkset indicated in the header,
ready to receive chunks for repair.
§Arguments
header- TheBlobHeaderof the blob to be repaired. This header provides the necessary metadata, including chunkset commitments, for the repair process.
§Returns
A new RepairingBlob instance, prepared to accept chunks for reconstruction.
Sourcepub fn add_chunk(
&mut self,
chunk: &ProofCarryingChunk,
) -> Result<(), DecdsError>
pub fn add_chunk( &mut self, chunk: &ProofCarryingChunk, ) -> Result<(), DecdsError>
Adds a ProofCarryingChunk to the appropriate RepairingChunkSet within the blob.
This method first validates the chunk’s inclusion using the blob header, then attempts to add it to the relevant chunkset’s decoder.
§Arguments
chunk- A reference to theProofCarryingChunkto add.
§Returns
Returns a Result which is:
Ok(())if the chunk is successfully added.Err(DecdsError::InvalidChunksetId)if the chunk’schunkset_iddoes not exist in this blob.Err(DecdsError::ChunksetAlreadyRepaired)if the target chunkset has already been repaired.Err(DecdsError::InvalidProofInChunk)if the chunk’s proof of inclusion in the blob or chunkset is invalid.Err(DecdsError::ChunksetReadyToRepair)if the chunkset is already ready to repair (and thus cannot accept more chunks).- Other
DecdsErrortypes may be returned fromRepairingChunkSet::add_chunk_unvalidated.
Sourcepub fn is_chunkset_ready_to_repair(
&self,
chunkset_id: usize,
) -> Result<bool, DecdsError>
pub fn is_chunkset_ready_to_repair( &self, chunkset_id: usize, ) -> Result<bool, DecdsError>
Checks if a specific chunkset within the blob is ready to be repaired (reconstructed).
§Arguments
chunkset_id- The ID of the chunkset to check.
§Returns
Returns a Result which is:
Ok(bool):trueif the chunkset is ready for repair,falseotherwise.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.
Sourcepub fn is_chunkset_already_repaired(
&self,
chunkset_id: usize,
) -> Result<bool, DecdsError>
pub fn is_chunkset_already_repaired( &self, chunkset_id: usize, ) -> Result<bool, DecdsError>
Checks if a specific chunkset within the blob has already been successfully repaired.
§Arguments
chunkset_id- The ID of the chunkset to check.
§Returns
Returns a Result which is:
Ok(bool):trueif the chunkset has already been repaired,falseotherwise.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.
Sourcepub fn get_repaired_chunkset(
&mut self,
chunkset_id: usize,
) -> Result<Vec<u8>, DecdsError>
pub fn get_repaired_chunkset( &mut self, chunkset_id: usize, ) -> Result<Vec<u8>, DecdsError>
Retrieves the repaired (reconstructed) data for a specific chunkset.
This method consumes the RepairingChunkSet for the given ID once successful,
as the data is fully reconstructed.
§Arguments
chunkset_id- The ID of the chunkset to retrieve repaired data for.
§Returns
Returns a Result which is:
Ok(Vec<u8>)containing the repaired chunkset data if successful.Err(DecdsError::ChunksetAlreadyRepaired)if the chunkset has already been repaired and retrieved.Err(DecdsError::ChunksetNotYetReadyToRepair)if not enough chunks have been added to repair the chunkset.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.Err(DecdsError::ChunksetRepairingFailed)if an error occurs during the underlying chunkset repair process.
Auto Trait Implementations§
impl Freeze for RepairingBlob
impl RefUnwindSafe for RepairingBlob
impl Send for RepairingBlob
impl Sync for RepairingBlob
impl Unpin for RepairingBlob
impl UnwindSafe for RepairingBlob
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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