Skip to content

Commit

Permalink
feat(tasks): add "AllBytesReceived" stage (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward authored Jun 11, 2021
1 parent 27fe22a commit 4b4dc8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tasks/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ var CommonStages = map[string]func() StageDetails{
var RetrievalStages = map[string]func() StageDetails{
"DealAccepted": staticStageDetails("Miner accepts deal", "a few seconds"),
"FirstByteReceived": staticStageDetails("First byte of data received from miner", "a few seconds, or several hours when unsealing"),
"DealComplete": staticStageDetails("All bytes received and deal is completed", "a few seconds"),
"AllBytesReceived": staticStageDetails("All bytes received, deal wrapping up", "a few seconds"),
"DealComplete": staticStageDetails("Deal is complete", "a few seconds"),
}

// the multi-codec and hash we use for cid links by default
Expand Down
9 changes: 7 additions & 2 deletions tasks/retrieval_deal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ const (
RetrievalStageProposeDeal = RetrievalStage("ProposeDeal")
RetrievalStageDealAccepted = RetrievalStage("DealAccepted")
RetrievalStageFirstByteReceived = RetrievalStage("FirstByteReceived")
RetrievalStageAllBytesReceived = RetrievalStage("AllBytesReceived")
RetrievalStageDealComplete = RetrievalStage("DealComplete")
)

var RetrievalDealStages = []RetrievalStage{
RetrievalStageProposeDeal,
RetrievalStageDealAccepted,
RetrievalStageFirstByteReceived,
RetrievalStageAllBytesReceived,
RetrievalStageDealComplete,
}

Expand Down Expand Up @@ -233,7 +235,7 @@ func (de *retrievalDealExecutor) executeAndMonitorDeal(ctx context.Context, upda
// steam closed, no errors, so the deal is a success

// deal is on chain, exit successfully
stage = RetrievalStageDealComplete
stage = RetrievalStageAllBytesReceived
dealStage = RetrievalStages[stage]()
dealStage = AddLog(dealStage, fmt.Sprintf("bytes received: %d", event.BytesReceived))
err = updateStage(ctx, stage, dealStage)
Expand All @@ -259,7 +261,10 @@ func (de *retrievalDealExecutor) executeAndMonitorDeal(ctx context.Context, upda
if de.task.CARExport.x {
return errors.New("car export not implemented")
}
return nil
// final stage
stage = RetrievalStageDealComplete
dealStage = RetrievalStages[stage]()
return updateStage(ctx, stage, dealStage)
}

// if the event has an error message, then something went wrong and deal failed
Expand Down

0 comments on commit 4b4dc8f

Please sign in to comment.