@@ -25,13 +25,13 @@ type stackFrame struct {
25
25
// This function makes no assumptions, other than maximum size, about the pieces that you include.
26
26
// To create a correctly formed UnsealedCID (CommD) for a sector using this method, you should first
27
27
// ensure that the pieces add up to the required size.
28
- func PieceAggregateCommP (proofType abi.RegisteredSealProof , pieceInfos []abi.PieceInfo ) (cid.Cid , error ) {
28
+ func PieceAggregateCommP (proofType abi.RegisteredSealProof , pieceInfos []abi.PieceInfo ) (cid.Cid , abi. PaddedPieceSize , error ) {
29
29
spi , found := abi .SealProofInfos [proofType ]
30
30
if ! found {
31
- return cid .Undef , fmt .Errorf ("unknown seal proof type %d" , proofType )
31
+ return cid .Undef , 0 , fmt .Errorf ("unknown seal proof type %d" , proofType )
32
32
}
33
33
if len (pieceInfos ) == 0 {
34
- return cid .Undef , errors .New ("no pieces provided" )
34
+ return cid .Undef , 0 , errors .New ("no pieces provided" )
35
35
}
36
36
37
37
maxSize := uint64 (spi .SectorSize )
@@ -41,18 +41,18 @@ func PieceAggregateCommP(proofType abi.RegisteredSealProof, pieceInfos []abi.Pie
41
41
// sancheck everything
42
42
for i , p := range pieceInfos {
43
43
if p .Size < 128 {
44
- return cid .Undef , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is too small" , i , p .Size )
44
+ return cid .Undef , 0 , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is too small" , i , p .Size )
45
45
}
46
46
if uint64 (p .Size ) > maxSize {
47
- return cid .Undef , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is larger than sector size of SealProofType %d" , i , p .Size , proofType )
47
+ return cid .Undef , 0 , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is larger than sector size of SealProofType %d" , i , p .Size , proofType )
48
48
}
49
49
if bits .OnesCount64 (uint64 (p .Size )) != 1 {
50
- return cid .Undef , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is not a power of 2" , i , p .Size )
50
+ return cid .Undef , 0 , fmt .Errorf ("invalid Size of PieceInfo %d: value %d is not a power of 2" , i , p .Size )
51
51
}
52
52
53
53
cp , err := commcid .CIDToPieceCommitmentV1 (p .PieceCID )
54
54
if err != nil {
55
- return cid .Undef , fmt .Errorf ("invalid PieceCid for PieceInfo %d: %w" , i , err )
55
+ return cid .Undef , 0 , fmt .Errorf ("invalid PieceCid for PieceInfo %d: %w" , i , err )
56
56
}
57
57
todo [i ] = stackFrame {size : uint64 (p .Size ), commP : cp }
58
58
}
@@ -106,10 +106,12 @@ func PieceAggregateCommP(proofType abi.RegisteredSealProof, pieceInfos []abi.Pie
106
106
}
107
107
108
108
if stack [0 ].size > maxSize {
109
- return cid .Undef , fmt .Errorf ("provided pieces sum up to %d bytes, which is larger than sector size of SealProofType %d" , stack [0 ].size , proofType )
109
+ return cid .Undef , 0 , fmt .Errorf ("provided pieces sum up to %d bytes, which is larger than sector size of SealProofType %d" , stack [0 ].size , proofType )
110
110
}
111
111
112
- return commcid .PieceCommitmentV1ToCID (stack [0 ].commP )
112
+ fincid , err := commcid .PieceCommitmentV1ToCID (stack [0 ].commP )
113
+
114
+ return fincid , abi .PaddedPieceSize (stack [0 ].size ), err
113
115
}
114
116
115
117
var s256pool = sync.Pool {New : func () any { return sha256simd .New () }}
0 commit comments