deals: call 'complete' handler
This commit is contained in:
parent
b88d23fd8b
commit
c275d1fb6a
@ -18,10 +18,12 @@ const (
|
|||||||
DealSealing
|
DealSealing
|
||||||
DealComplete
|
DealComplete
|
||||||
|
|
||||||
// Client specific
|
// Internal
|
||||||
|
|
||||||
DealError // deal failed with an unexpected error
|
DealError // deal failed with an unexpected error
|
||||||
DealExpired
|
DealExpired
|
||||||
|
|
||||||
|
DealNoUpdate = DealUnknown
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: check if this exists anywhere else
|
// TODO: check if this exists anywhere else
|
||||||
|
@ -189,6 +189,8 @@ func (h *Handler) onUpdated(ctx context.Context, update minerDealUpdate) {
|
|||||||
h.handle(ctx, deal, h.staged, api.DealSealing)
|
h.handle(ctx, deal, h.staged, api.DealSealing)
|
||||||
case api.DealSealing:
|
case api.DealSealing:
|
||||||
h.handle(ctx, deal, h.sealing, api.DealComplete)
|
h.handle(ctx, deal, h.sealing, api.DealComplete)
|
||||||
|
case api.DealComplete:
|
||||||
|
h.handle(ctx, deal, h.complete, api.DealNoUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
func (h *Handler) handle(ctx context.Context, deal MinerDeal, cb minerHandlerFunc, next api.DealState) {
|
||||||
go func() {
|
go func() {
|
||||||
mut, err := cb(ctx, deal)
|
mut, err := cb(ctx, deal)
|
||||||
|
|
||||||
|
if err == nil && next == api.DealNoUpdate {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case h.updated <- minerDealUpdate{
|
case h.updated <- minerDealUpdate{
|
||||||
newState: next,
|
newState: next,
|
||||||
|
Loading…
Reference in New Issue
Block a user