pub fn put_coding_blob_bytes(&self, slot: u64, index: u64, bytes: &[u8]) -> Result<()> {
        let set_index = ErasureMeta::set_index_for(index);
        let mut batch_processor = self.batch_processor.write().unwrap();

        let mut erasure_meta = self
            .erasure_meta_cf
            .get((slot, set_index))?
            .unwrap_or_else(|| ErasureMeta::new(set_index));

        erasure_meta.set_coding_present(index, true);
        erasure_meta.set_size(bytes.len() - BLOB_HEADER_SIZE);

        let mut writebatch = batch_processor.batch()?;

        writebatch.put_bytes::<cf::Coding>((slot, index), bytes)?;

        let recovered_data = {
            if let Some((data, coding)) = try_erasure_recover(
                &self.db,
                &self.session,
                &erasure_meta,
                slot,
                &HashMap::new(),
                Some((index, bytes)),
            )? {
                let mut erasure_meta_working_set = HashMap::new();
                erasure_meta_working_set.insert((slot, set_index), erasure_meta);
                erasure_meta = *erasure_meta_working_set.values().next().unwrap();

                for coding_blob in coding {
                    erasure_meta.set_coding_present(coding_blob.index(), true);

                    writebatch.put_bytes::<cf::Coding>(
                        (coding_blob.slot(), coding_blob.index()),
                        &coding_blob.data[..BLOB_HEADER_SIZE + coding_blob.size()],
                    )?;
                }
                Some(data)
            } else {
                None
            }
        };

        writebatch.put::<cf::ErasureMeta>((slot, set_index), &erasure_meta)?;
        batch_processor.write(writebatch)?;
        drop(batch_processor);
        if let Some(data) = recovered_data {
            if !data.is_empty() {
                self.insert_data_blobs(&data)?;
            }
        }

        Ok(())
    }
/// this function will insert coding blobs and also automatically track erasure-related
/// metadata. If recovery is available it will be done
this function will insert coding blobs and also automatically track erasure-related
metadata. If recovery is available it will be done
this function will insert coding blobs and also automatically track erasure - related metadata . If recovery is available it will be done
pub fn put_coding_blob_bytes(&self, slot: u64, index: u64, bytes: &[u8]) -> Result<()> {
        let set_index = ErasureMeta::set_index_for(index);
        let mut batch_processor = self.batch_processor.write().unwrap();
        let mut erasure_meta = self
            .erasure_meta_cf
            .get((slot, set_index))?
            .unwrap_or_else(|| ErasureMeta::new(set_index));
        erasure_meta.set_coding_present(index, true);
        erasure_meta.set_size(bytes.len() - BLOB_HEADER_SIZE);
        let mut writebatch = batch_processor.batch()?;
        writebatch.put_bytes::<cf::Coding>((slot, index), bytes)?;
        let recovered_data = {
            if let Some((data, coding)) = try_erasure_recover(
                &self.db,
                &self.session,
                &erasure_meta,
                slot,
                &HashMap::new(),
                Some((index, bytes)),
            )? {
                let mut erasure_meta_working_set = HashMap::new();
                erasure_meta_working_set.insert((slot, set_index), erasure_meta);
                erasure_meta = *erasure_meta_working_set.values().next().unwrap();
                for coding_blob in coding {
                    erasure_meta.set_coding_present(coding_blob.index(), true);
                    writebatch.put_bytes::<cf::Coding>(
                        (coding_blob.slot(), coding_blob.index()),
                        &coding_blob.data[..BLOB_HEADER_SIZE + coding_blob.size()],
                    )?;
                }
                Some(data)
            } else {
                None
            }
        };
        writebatch.put::<cf::ErasureMeta>((slot, set_index), &erasure_meta)?;
        batch_processor.write(writebatch)?;
        drop(batch_processor);
        if let Some(data) = recovered_data {
            if !data.is_empty() {
                self.insert_data_blobs(&data)?;
            }
        }
        Ok(())
    }
pub fn put_coding_blob_bytes ( & self , slot : u64 , index : u64 , bytes : & [ u8 ] ) -> Result < ( ) > { let set_index = ErasureMeta :: set_index_for ( index ) ; let mut batch_processor = self . batch_processor . write ( ) . unwrap ( ) ; let mut erasure_meta = self . erasure_meta_cf . get ( ( slot , set_index ) ) ? . unwrap_or_else ( | | ErasureMeta :: new ( set_index ) ) ; erasure_meta . set_coding_present ( index , true ) ; erasure_meta . set_size ( bytes . len ( ) - BLOB_HEADER_SIZE ) ; let mut writebatch = batch_processor . batch ( ) ? ; writebatch . put_bytes :: < cf :: Coding > ( ( slot , index ) , bytes ) ? ; let recovered_data = { if let Some ( ( data , coding ) ) = try_erasure_recover ( & self . db , & self . session , & erasure_meta , slot , & HashMap :: new ( ) , Some ( ( index , bytes ) ) , ) ? { let mut erasure_meta_working_set = HashMap :: new ( ) ; erasure_meta_working_set . insert ( ( slot , set_index ) , erasure_meta ) ; erasure_meta = * erasure_meta_working_set . values ( ) . next ( ) . unwrap ( ) ; for coding_blob in coding { erasure_meta . set_coding_present ( coding_blob . index ( ) , true ) ; writebatch . put_bytes :: < cf :: Coding > ( ( coding_blob . slot ( ) , coding_blob . index ( ) ) , & coding_blob . data [ .. BLOB_HEADER_SIZE + coding_blob . size ( ) ] , ) ? ; } Some ( data ) } else { None } } ; writebatch . put :: < cf :: ErasureMeta > ( ( slot , set_index ) , & erasure_meta ) ? ; batch_processor . write ( writebatch ) ? ; drop ( batch_processor ) ; if let Some ( data ) = recovered_data { if ! data . is_empty ( ) { self . insert_data_blobs ( & data ) ? ; } } Ok ( ( ) ) }
this function will insert coding blobs and also automatically track erasure-related
metadata.
this function will insert coding blobs and also automatically track erasure - related metadata .
&self
slot
u64
index
u64
bytes
&[u8]
&self
slot
u64
index
u64
bytes
&[u8]