pub fn generate_piece_commitment<T: std::io::Read>(
    source: T,
    piece_size: UnpaddedBytesAmount,
) -> Result<PieceInfo> {
    info!("generate_piece_commitment:start");

    let result = measure_op(Operation::GeneratePieceCommitment, || {
        ensure_piece_size(piece_size)?;

        // send the source through the preprocessor
        let source = std::io::BufReader::new(source);
        let mut fr32_reader = crate::fr32_reader::Fr32Reader::new(source);

        let commitment = generate_piece_commitment_bytes_from_source::<DefaultPieceHasher>(
            &mut fr32_reader,
            PaddedBytesAmount::from(piece_size).into(),
        )?;

        PieceInfo::new(commitment, piece_size)
    });

    info!("generate_piece_commitment:finish");
    result
}
/// Generates a piece commitment for the provided byte source. Returns an error
/// if the byte source produced more than `piece_size` bytes.
///
/// # Arguments
///
/// * `source` - a readable source of unprocessed piece bytes. The piece's commitment will be
/// generated for the bytes read from the source plus any added padding.
/// * `piece_size` - the number of unpadded user-bytes which can be read from source before EOF.
Generates a piece commitment for the provided byte source. Returns an error
if the byte source produced more than `piece_size` bytes.
Generates a piece commitment for the provided byte source . Returns an error if the byte source produced more than ` piece_size ` bytes .
pub fn generate_piece_commitment<T: std::io::Read>(
    source: T,
    piece_size: UnpaddedBytesAmount,
) -> Result<PieceInfo> {
    info!("generate_piece_commitment:start");
    let result = measure_op(Operation::GeneratePieceCommitment, || {
        ensure_piece_size(piece_size)?;
        // send the source through the preprocessor
        let source = std::io::BufReader::new(source);
        let mut fr32_reader = crate::fr32_reader::Fr32Reader::new(source);
        let commitment = generate_piece_commitment_bytes_from_source::<DefaultPieceHasher>(
            &mut fr32_reader,
            PaddedBytesAmount::from(piece_size).into(),
        )?;
        PieceInfo::new(commitment, piece_size)
    });
    info!("generate_piece_commitment:finish");
    result
}
pub fn generate_piece_commitment < T : std :: io :: Read > ( source : T , piece_size : UnpaddedBytesAmount , ) -> Result < PieceInfo > { info ! ( " " ) ; let result = measure_op ( Operation :: GeneratePieceCommitment , | | { ensure_piece_size ( piece_size ) ? ; // send the source through the preprocessor let source = std :: io :: BufReader :: new ( source ) ; let mut fr32_reader = crate :: fr32_reader :: Fr32Reader :: new ( source ) ; let commitment = generate_piece_commitment_bytes_from_source :: < DefaultPieceHasher > ( & mut fr32_reader , PaddedBytesAmount :: from ( piece_size ) . into ( ) , ) ? ; PieceInfo :: new ( commitment , piece_size ) } ) ; info ! ( " " ) ; result }
Generates a piece commitment for the provided byte source.
Generates a piece commitment for the provided byte source .
source
T
piece_size
UnpaddedBytesAmount
source
T
piece_size
UnpaddedBytesAmount