fix: mock sealer: grab lock in ReadPiece

This commit is contained in:
Aayush 2022-08-23 17:24:28 -04:00
parent 4a6ea4c492
commit 5e80276631

View File

@ -439,6 +439,9 @@ func (mgr *SectorMgr) GenerateWindowPoStWithVanilla(ctx context.Context, proofTy
func (mgr *SectorMgr) ReadPiece(ctx context.Context, sector storiface.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, ticket abi.SealRandomness, unsealed cid.Cid) (mount.Reader, bool, error) {
off := storiface.UnpaddedByteIndex(0)
var piece cid.Cid
mgr.lk.Lock()
for _, c := range mgr.sectors[sector.ID].pieces {
piece = c
if off >= offset {
@ -451,6 +454,8 @@ func (mgr *SectorMgr) ReadPiece(ctx context.Context, sector storiface.SectorRef,
}
br := bytes.NewReader(mgr.pieces[piece][:size])
mgr.lk.Unlock()
return struct {
io.ReadCloser
io.Seeker