Skip to main content

RecordsEncoder

Trait RecordsEncoder 

Source
pub trait RecordsEncoder {
    // Required method
    fn encode_records(
        &mut self,
        sector_id: &SectorId,
        records: &mut [Record],
        abort_early: &AtomicBool,
    ) -> Result<SectorContentsMap>;
}
Expand description

Records encoder for plotting purposes.

Each record is erasure coded and proofs of space are generated for it. The proofs must be the ones that [TableGenerator::create_proofs()] returns for sector_id.derive_evaluation_seed(piece_offset), because reading and proving create them again the same way. There are exactly [Record::NUM_CHUNKS] of them. The record is then replaced with the chunks at the s-buckets of those proofs, each XORed with the hash of its proof, in s-bucket order. The returned sector contents map has one entry per record with a bit set for each of those s-buckets.

encode_sector() checks the number of entries and the number of bits in each entry, but not which bits are set. Bits that don’t match the proofs result in a sector that can’t be read or proven.

Required Methods§

Source

fn encode_records( &mut self, sector_id: &SectorId, records: &mut [Record], abort_early: &AtomicBool, ) -> Result<SectorContentsMap>

Encode provided sector records.

Encoding may stop early once abort_early is set. The returned map is not used in that case.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<PosTable> RecordsEncoder for CpuRecordsEncoder<'_, PosTable>
where PosTable: Table,