attempt to do better padding on pieces being written into sectors
This commit is contained in:
parent
7e25a811c3
commit
6daaf6ac2e
15
extern/sector-storage/ffiwrapper/sealer_cgo.go
vendored
15
extern/sector-storage/ffiwrapper/sealer_cgo.go
vendored
@ -195,12 +195,16 @@ func (sb *Sealer) AddPiece(ctx context.Context, sector storage.SectorRef, existi
|
|||||||
return piecePromises[0]()
|
return piecePromises[0]()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var payloadRoundedBytes abi.PaddedPieceSize
|
||||||
pieceCids := make([]abi.PieceInfo, len(piecePromises))
|
pieceCids := make([]abi.PieceInfo, len(piecePromises))
|
||||||
for i, promise := range piecePromises {
|
for i, promise := range piecePromises {
|
||||||
pieceCids[i], err = promise()
|
pinfo, err := promise()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return abi.PieceInfo{}, err
|
return abi.PieceInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pieceCids[i] = pinfo
|
||||||
|
payloadRoundedBytes += pinfo.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
pieceCID, err := ffi.GenerateUnsealedCID(sector.ProofType, pieceCids)
|
pieceCID, err := ffi.GenerateUnsealedCID(sector.ProofType, pieceCids)
|
||||||
@ -208,6 +212,15 @@ func (sb *Sealer) AddPiece(ctx context.Context, sector storage.SectorRef, existi
|
|||||||
return abi.PieceInfo{}, xerrors.Errorf("generate unsealed CID: %w", err)
|
return abi.PieceInfo{}, xerrors.Errorf("generate unsealed CID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if payloadRoundedBytes < pieceSize.Padded() {
|
||||||
|
paddedCid, err := commpffi.ZeroPadPieceCommitment(pieceCID, payloadRoundedBytes.Unpadded(), pieceSize)
|
||||||
|
if err != nil {
|
||||||
|
return abi.PieceInfo{}, xerrors.Errorf("failed to pad data: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pieceCID = paddedCid
|
||||||
|
}
|
||||||
|
|
||||||
// validate that the pieceCID was properly formed
|
// validate that the pieceCID was properly formed
|
||||||
if _, err := commcid.CIDToPieceCommitmentV1(pieceCID); err != nil {
|
if _, err := commcid.CIDToPieceCommitmentV1(pieceCID); err != nil {
|
||||||
return abi.PieceInfo{}, err
|
return abi.PieceInfo{}, err
|
||||||
|
Loading…
Reference in New Issue
Block a user