This commit is contained in:
Łukasz Magiera 2021-01-10 22:54:21 +01:00
parent 9e74c3c4e8
commit 5462ecf6da
2 changed files with 12 additions and 6 deletions

View File

@ -142,7 +142,10 @@ func (sb *Sealer) AddPiece(ctx context.Context, sector storage.SectorRef, existi
break
}
done := make(chan struct{cid.Cid; error}, 1)
done := make(chan struct {
cid.Cid
error
}, 1)
pbuf := <-throttle
copy(pbuf, buf[:read])
@ -152,7 +155,10 @@ func (sb *Sealer) AddPiece(ctx context.Context, sector storage.SectorRef, existi
}()
c, err := sb.pieceCid(sector.ProofType, pbuf[:read])
done <- struct {cid.Cid; error }{c, err}
done <- struct {
cid.Cid
error
}{c, err}
}(read)
piecePromises = append(piecePromises, func() (abi.PieceInfo, error) {

View File

@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
"io"
"io/ioutil"
"math/rand"
@ -34,6 +33,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
)
func init() {
@ -654,7 +654,7 @@ func TestAddPiece512M(t *testing.T) {
r := rand.New(rand.NewSource(0x7e5))
c, err := sb.AddPiece(context.TODO(), storage.SectorRef{
ID: abi.SectorID{
ID: abi.SectorID{
Miner: miner,
Number: 0,
},
@ -697,7 +697,7 @@ func BenchmarkAddPiece512M(b *testing.B) {
for i := 0; i < b.N; i++ {
c, err := sb.AddPiece(context.TODO(), storage.SectorRef{
ID: abi.SectorID{
ID: abi.SectorID{
Miner: miner,
Number: abi.SectorNumber(i),
},