check for deal start epoch on SectorAddPieceToAny

This commit is contained in:
Anton Evangelatov
2021-10-01 17:42:09 +02:00
committed by Łukasz Magiera
parent edcb28737c
commit c2fa54ca9c
+10
View File
@@ -274,6 +274,16 @@ func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPiec
return api.SectorOffset{}, xerrors.Errorf("getting proposal CID: %w", err)
}
_, head, err := m.Api.ChainHead(ctx)
if err != nil {
return api.SectorOffset{}, xerrors.Errorf("couldnt get chain head: %w", err)
}
if head > deal.DealProposal.StartEpoch {
return api.SectorOffset{}, xerrors.Errorf(
"cannot add piece for deal with piece CID %s: current epoch %d has passed deal proposal start epoch %d",
deal.DealProposal.PieceCID, head, deal.DealProposal.StartEpoch)
}
m.inputLk.Lock()
if _, exist := m.pendingPieces[proposalCID(deal)]; exist {
m.inputLk.Unlock()