changes as per review

This commit is contained in:
Aarsh Shah 2022-02-21 18:27:51 +04:00
parent c2522e8ca9
commit 56926b349a
2 changed files with 4 additions and 5 deletions

View File

@ -315,7 +315,7 @@ func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPiec
m.inputLk.Unlock() m.inputLk.Unlock()
select { select {
case <-pp.doneCh: case <-pp.doneCh:
res := pp.resp.Load().(*pieceAcceptResp) res := pp.resp
return api.SectorOffset{Sector: res.sn, Offset: res.offset.Padded()}, res.err return api.SectorOffset{Sector: res.sn, Offset: res.offset.Padded()}, res.err
case <-ctx.Done(): case <-ctx.Done():
return api.SectorOffset{}, ctx.Err() return api.SectorOffset{}, ctx.Err()
@ -331,7 +331,7 @@ func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPiec
assigned: false, assigned: false,
} }
pp.accepted = func(sn abi.SectorNumber, offset abi.UnpaddedPieceSize, err error) { pp.accepted = func(sn abi.SectorNumber, offset abi.UnpaddedPieceSize, err error) {
pp.resp.Store(&pieceAcceptResp{sn, offset, err}) pp.resp = &pieceAcceptResp{sn, offset, err}
close(pp.doneCh) close(pp.doneCh)
} }
@ -345,7 +345,7 @@ func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPiec
select { select {
case <-doneCh: case <-doneCh:
res := pp.resp.Load().(*pieceAcceptResp) res := pp.resp
return api.SectorOffset{Sector: res.sn, Offset: res.offset.Padded()}, res.err return api.SectorOffset{Sector: res.sn, Offset: res.offset.Padded()}, res.err
case <-ctx.Done(): case <-ctx.Done():
return api.SectorOffset{}, ctx.Err() return api.SectorOffset{}, ctx.Err()

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"sync" "sync"
"sync/atomic"
"time" "time"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -149,7 +148,7 @@ type pieceAcceptResp struct {
type pendingPiece struct { type pendingPiece struct {
doneCh chan struct{} doneCh chan struct{}
resp atomic.Value resp *pieceAcceptResp
size abi.UnpaddedPieceSize size abi.UnpaddedPieceSize
deal api.PieceDealInfo deal api.PieceDealInfo