Function filecoin_proofs_api::seal::add_piece
source · pub fn add_piece<R, W>(
registered_proof: RegisteredSealProof,
source: R,
target: W,
piece_size: UnpaddedBytesAmount,
piece_lengths: &[UnpaddedBytesAmount],
) -> Result<(PieceInfo, UnpaddedBytesAmount)>
Expand description
Computes a NUL-byte prefix and/or suffix for source
using the provided
piece_lengths
and piece_size
(such that the source
, after
preprocessing, will occupy a subtree of a Merkle tree built using the bytes
from target
), runs the resultant byte stream through the preprocessor,
and writes the result to target
. Returns a tuple containing the number of
bytes written to target
(source
plus alignment) and the commitment.
WARNING: Depending on the ordering and size of the pieces in
piece_lengths
, this function could write a prefix of NUL bytes which
wastes ($SIZESECTORSIZE/2)-$MINIMUM_PIECE_SIZE space. This function will be
deprecated in favor of write_and_preprocess
, and miners will be prevented
from sealing sectors containing more than $TOOMUCH alignment bytes.
§Arguments
registered_proof
- Selected seal proof for this byte source.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.piece_lengths
- The number of bytes for each previous piece in the sector.
Returns a tuple containing the number of bytes written to target
(source
plus alignment)
and the commitment.