deals: call 'complete' handler

This commit is contained in:
Łukasz Magiera 2019-09-16 20:04:15 +02:00
parent b88d23fd8b
commit c275d1fb6a
3 changed files with 10 additions and 1 deletions

View File

@ -18,10 +18,12 @@ const (
DealSealing
DealComplete
// Client specific
// Internal
DealError // deal failed with an unexpected error
DealExpired
DealNoUpdate = DealUnknown
)
// TODO: check if this exists anywhere else

View File

@ -189,6 +189,8 @@ func (h *Handler) onUpdated(ctx context.Context, update minerDealUpdate) {
h.handle(ctx, deal, h.staged, api.DealSealing)
case api.DealSealing:
h.handle(ctx, deal, h.sealing, api.DealComplete)
case api.DealComplete:
h.handle(ctx, deal, h.complete, api.DealNoUpdate)
}
}

View File

@ -22,6 +22,11 @@ type minerHandlerFunc func(ctx context.Context, deal MinerDeal) (func(*MinerDeal
func (h *Handler) handle(ctx context.Context, deal MinerDeal, cb minerHandlerFunc, next api.DealState) {
go func() {
mut, err := cb(ctx, deal)
if err == nil && next == api.DealNoUpdate {
return
}
select {
case h.updated <- minerDealUpdate{
newState: next,