File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,13 @@ type stackFrame struct {
1717 commP []byte
1818}
1919
20- // GenerateUnsealedCID generates the UnsealedCID (CommD) for a sector of size determined by the
21- // proofType from the provided pieceInfos by merkleization the CommPs of the pieces .
20+ // PieceAggregateCommP generates an aggregate CommP for a list of pieces that combine in size up to
21+ // the sector size determined by the proofType parameter .
2222//
23- // This function **assumes** that the pieces are already padded to the sector size and may not
24- // return the correct result if this is not the case.
25- func GenerateUnsealedCID (proofType abi.RegisteredSealProof , pieceInfos []abi.PieceInfo ) (cid.Cid , error ) {
23+ // This function makes no assumptions, other than maximum size, about the pieces that you include.
24+ // To create a correctly formed UnsealedCID (CommD) for a sector using this method, you should first
25+ // ensure that the pieces add up to the required size.
26+ func PieceAggregateCommP (proofType abi.RegisteredSealProof , pieceInfos []abi.PieceInfo ) (cid.Cid , error ) {
2627 spi , found := abi .SealProofInfos [proofType ]
2728 if ! found {
2829 return cid .Undef , fmt .Errorf ("unknown seal proof type %d" , proofType )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ func TestGenerateUnsealedCID(t *testing.T) {
2626
2727 expCommD := cidMustParse ("baga6ea4seaqiw3gbmstmexb7sqwkc5r23o3i7zcyx5kr76pfobpykes3af62kca" )
2828
29- commD , _ := commp .GenerateUnsealedCID (
29+ commD , _ := commp .PieceAggregateCommP (
3030 abi .RegisteredSealProof_StackedDrg32GiBV1_1 , // 32G sector SP
3131 []abi.PieceInfo {
3232 {PieceCID : cidMustParse ("baga6ea4seaqknzm22isnhsxt2s4dnw45kfywmhenngqq3nc7jvecakoca6ksyhy" ), Size : 256 << 20 }, // https://filfox.info/en/deal/3755444
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ func (w *Writer) Sum() (DataCIDSize, error) {
144144 }
145145 }
146146
147- p , err := commp .GenerateUnsealedCID (abi .RegisteredSealProof_StackedDrg64GiBV1 , pieces )
147+ p , err := commp .PieceAggregateCommP (abi .RegisteredSealProof_StackedDrg64GiBV1 , pieces )
148148 if err != nil {
149149 return DataCIDSize {}, xerrors .Errorf ("generating unsealed CID: %w" , err )
150150 }
You can’t perform that action at this time.
0 commit comments