diff --git a/codex/sales.nim b/codex/sales.nim index b57718a2..b68f9ccc 100644 --- a/codex/sales.nim +++ b/codex/sales.nim @@ -373,7 +373,7 @@ proc subscribeCancellation(sales: Sales) {.async.} = let queue = context.slotQueue proc onCancelled(requestId: RequestId) = - trace "request cancelled, removing all request slots from queue" + trace "request cancelled (via contract RequestCancelled event), removing all request slots from queue" queue.delete(requestId) try: diff --git a/codex/sales/states/proving.nim b/codex/sales/states/proving.nim index 22cd50b4..e4059f6d 100644 --- a/codex/sales/states/proving.nim +++ b/codex/sales/states/proving.nim @@ -79,27 +79,13 @@ proc proveLoop( method `$`*(state: SaleProving): string = "SaleProving" method onCancelled*(state: SaleProving, request: StorageRequest): ?State = - if not state.loop.isNil: - if not state.loop.finished: - try: - waitFor state.loop.cancelAndWait() - except CatchableError as e: - error "Error during cancelation of prooving loop", msg = e.msg - - state.loop = nil - + # state.loop cancellation happens automatically when run is cancelled due to + # state change return some State(SaleCancelled()) method onFailed*(state: SaleProving, request: StorageRequest): ?State = - if not state.loop.isNil: - if not state.loop.finished: - try: - waitFor state.loop.cancelAndWait() - except CatchableError as e: - error "Error during cancelation of prooving loop", msg = e.msg - - state.loop = nil - + # state.loop cancellation happens automatically when run is cancelled due to + # state change return some State(SaleFailed()) method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =