remove waitFor cancelAndWait in proving state (#643)
In proving.onCancelled, the `waitFor state.loop.cancelAndWait()` was never completing. Turns out this was not needed, because when changing states, the current state's run is cancelled, which automatically cancels the state prove loop, because it is a child of proving.run. Therefore, the logic to cancelAndWait the prove loop was removed as it was not needed.
This commit is contained in:
parent
b38146d3f7
commit
86a6ef9215
|
@ -373,7 +373,7 @@ proc subscribeCancellation(sales: Sales) {.async.} =
|
||||||
let queue = context.slotQueue
|
let queue = context.slotQueue
|
||||||
|
|
||||||
proc onCancelled(requestId: RequestId) =
|
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)
|
queue.delete(requestId)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -79,27 +79,13 @@ proc proveLoop(
|
||||||
method `$`*(state: SaleProving): string = "SaleProving"
|
method `$`*(state: SaleProving): string = "SaleProving"
|
||||||
|
|
||||||
method onCancelled*(state: SaleProving, request: StorageRequest): ?State =
|
method onCancelled*(state: SaleProving, request: StorageRequest): ?State =
|
||||||
if not state.loop.isNil:
|
# state.loop cancellation happens automatically when run is cancelled due to
|
||||||
if not state.loop.finished:
|
# state change
|
||||||
try:
|
|
||||||
waitFor state.loop.cancelAndWait()
|
|
||||||
except CatchableError as e:
|
|
||||||
error "Error during cancelation of prooving loop", msg = e.msg
|
|
||||||
|
|
||||||
state.loop = nil
|
|
||||||
|
|
||||||
return some State(SaleCancelled())
|
return some State(SaleCancelled())
|
||||||
|
|
||||||
method onFailed*(state: SaleProving, request: StorageRequest): ?State =
|
method onFailed*(state: SaleProving, request: StorageRequest): ?State =
|
||||||
if not state.loop.isNil:
|
# state.loop cancellation happens automatically when run is cancelled due to
|
||||||
if not state.loop.finished:
|
# state change
|
||||||
try:
|
|
||||||
waitFor state.loop.cancelAndWait()
|
|
||||||
except CatchableError as e:
|
|
||||||
error "Error during cancelation of prooving loop", msg = e.msg
|
|
||||||
|
|
||||||
state.loop = nil
|
|
||||||
|
|
||||||
return some State(SaleFailed())
|
return some State(SaleFailed())
|
||||||
|
|
||||||
method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =
|
method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =
|
||||||
|
|
Loading…
Reference in New Issue