Function filecoin_proofs::write_and_preprocess

source ·
pub fn write_and_preprocess<R, W>(
    source: R,
    target: W,
    piece_size: UnpaddedBytesAmount,
) -> Result<(PieceInfo, UnpaddedBytesAmount)>
where R: Read, W: Write,
Expand description

Writes bytes from source to target, adding bit-padding (“preprocessing”) as needed. Returns a tuple containing the number of bytes written to target and the commitment.

WARNING: This function neither prepends nor appends alignment bytes to the target; it is the caller’s responsibility to ensure properly sized and ordered writes to target such that source-bytes occupy whole subtrees of the final merkle tree built over target.

§Arguments

  • source - a readable source of unprocessed piece bytes.
  • target - a writer where we will write the processed piece bytes.
  • piece_size - the number of unpadded user-bytes which can be read from source before EOF.